feat: generate status-dependent action attempt properties as nullable - #322
Merged
Merged
Conversation
Bump @seamapi/blueprint to ^1.10.0 and consume its per-property actionAttemptStatuses annotation. An action attempt property that the API only populates for some statuses now generates as a nullable C# type, with documentation naming the statuses that populate it. In practice every variant's result becomes nullable, documented as null unless the action attempt status is success; error was already declared nullable on the union base. The generated sources are regenerated and formatted by the Generate workflow on push. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
…otations-f216kn' into claude/action-attempt-status-annotations-f216kn
Each action type is now a nested union discriminated on status: a pending subclass with no error or result members, a success subclass with a non-null result, an error subclass with a non-null error, and an unrecognized fallback preserving the raw payload. Property placement comes from the actionAttemptStatuses annotation, so dereferencing a status-dependent property without narrowing to its status subclass does not compile. SeamActionAttemptFailedException reads the error from the status subclass that carries it and falls back when none does. The generated sources are regenerated and formatted by the Generate workflow on push. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
…otations-f216kn' into claude/action-attempt-status-annotations-f216kn
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this means for SDK users
Every action attempt now deserializes to a subclass for its exact
(action_type, status)pair, soErrorandResultexist only where the API actually populates them:Unknown discriminator values still fall back safely with the raw payload preserved: an unknown
action_typegivesActionAttemptUnrecognized, an unknownstatusgives e.g.ActionAttemptLockDoorUnrecognized.attempt.Statusandattempt.ActionAttemptIdstay on the base for polymorphic reads, and the waiter (waitForActionAttempt) behaves exactly as before. A failed attempt without an error object raisesSeamActionAttemptFailedExceptionwith the message "Action attempt failed" instead of assuming one.Runtime API behavior is unchanged — the API always sent
null; the types just stopped lying about it. Code that readattempt.Error/attempt.Resultoff the base type must now pattern-match on the status subclass.How
Bumps
@seamapi/blueprintfrom ^1.8.0 to ^1.10.0, which annotates each action-attempt property with the statuses that populate it. The generator nests a secondSeamUnionlevel under each action type — the existing converter composes for nested unions with no runtime changes. Property placement per status comes from the annotation alone; thestatus/errorwire types remain the runtime-ownedActionAttemptStatus/ActionAttemptErrorthe resolver depends on.@seamapi/typesstays at 1.1034.0 (the annotations are complete against it; bumping would import unrelated API churn). The blueprint 1.9.x ordering change reorders request parameters in 7 Routes files — mechanical churn from the bump.Generated sources are produced by this repo's Generate workflow on push (it runs
npm run generate+ csharpier and auto-commits), so this PR carries the codegen change, dependency bumps, runtime exception change, and tests.Verification
Built and tested locally on net8.0: 175/175 tests pass, including new tests for pending/success/error subclass deserialization, unknown-status fallback with raw JSON, and the exception fallback without an error object. The wait-for-action-attempt integration tests exercise the failure path end to end. Codegen tsc + eslint + prettier clean; regeneration is deterministic. Not run locally: the net10.0 target and csharpier (CI covers both).
🤖 Generated with Claude Code
https://claude.ai/code/session_01EdWS7o3htQ9cNxhCWL5Frp