Skip to content

fix(api-sync): widen untyped body literals before conditional field assignment - #25

Merged
ericviana merged 1 commit into
mainfrom
eric/fix-refund-wallet-field
Aug 4, 2026
Merged

fix(api-sync): widen untyped body literals before conditional field assignment#25
ericviana merged 1 commit into
mainfrom
eric/fix-refund-wallet-field

Conversation

@ericviana

Copy link
Copy Markdown
Member

Summary

The API Sync workflow failed with:

src/commands/resources.ts(529,57): error TS2339: Property 'refund_wallet_address' does not exist on type '{ bank_account_id: string; network: string; token: string; request_amount: number; }'.

This is a bug in the deterministic generator (scripts/api-sync/apply.ts), not a spec problem: refund_wallet_address is a live, currently-supported field on QuoteIn (confirmed against origin/api-sync-data:.api-sync/spec-current.json, and it is read and used by the refund-on-failure job in the API). applyResourcesField always inserts if (options.x !== undefined) body.field = options.x after the existing body declaration. That only typechecks when body is already declared Record<string, any> (e.g. createBankAccount, updateCustomer). Functions that still declare a plain const body = {...} literal (like createQuote) get a closed object type from TS, so the new assignment fails to compile.

Fix

applyResourcesField now widens an untyped const body = { to const body: Record<string, any> = { whenever it adds a conditional field assignment, matching the convention already used by every hand-written function that assigns fields conditionally.

Verification

Reran the real changelog from origin/api-sync-data through the generator locally with the fix applied: it produces the same quotes.create: +refund_wallet_address change as before, but the result now passes bun run typecheck, bun run lint, bun test, and bun run build. Reverted that generated diff before committing since it's the API Sync workflow's job to produce and merge it, not this PR's.

Test plan

  • bun run typecheck
  • bun run lint
  • bun test (125 pass, including two new regression tests: widening an untyped body, and leaving an already-typed body untouched)
  • bun run build
  • Rerun the failed API Sync workflow run and confirm it completes green

https://claude.ai/code/session_01F1stiNzuNtJXoXtiW9ZCbs

…ssignment

The generator's applyResourcesField always inserts
"if (options.x !== undefined) body.field = options.x" after a function's
existing body declaration. That only typechecks when body is already
Record<string, any> (createBankAccount, updateCustomer, ...); functions
that still declare a plain "const body = {...}" literal (createQuote,
createPayin, ...) get a closed object type, so the new assignment fails
with TS2339. This is what broke the API Sync run that tried to add
refund_wallet_address to createQuote's body: the field itself is live on
the current QuoteIn schema and used by the payouts refund path, only the
generator's patch was wrong.

Widen the declaration to Record<string, any> whenever the generator adds
a conditional field to an untyped body literal, matching the convention
already used by hand-written conditional-field functions.

Claude-Session: https://claude.ai/code/session_01F1stiNzuNtJXoXtiW9ZCbs
@ericviana
ericviana merged commit eef7f45 into main Aug 4, 2026
1 check passed
@ericviana
ericviana deleted the eric/fix-refund-wallet-field branch August 4, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant