Skip to content

fix(cli): omit absent optional request bodies - #57

Merged
robinbraemer merged 1 commit into
mainfrom
codex/fix-optional-generated-body
Sep 10, 2026
Merged

robinbraemer merged 1 commit into
mainfrom
codex/fix-optional-generated-body

Conversation

@robinbraemer

Copy link
Copy Markdown
Member

Problem\n\nGenerated commands decoded an absent optional OpenAPI request body as undefined, then the shared Effect HTTP client encoded it as JSON. Body-less public operations therefore sent a JSON content type/body and could fail server validation (for example, order-draft worker-bootstrap creation).\n\n## Change\n\n- Skip HTTP body encoding only when the endpoint explicitly allows HttpApiSchema.NoContent and the generated payload is undefined.\n- Keep explicit JSON body values unchanged.\n- Reject explicit null during generated input decoding before transport.\n\n## Verification\n\n- RED: intercepted generated command transport received application/json for an omitted optional body.\n- GREEN: omitted body has no content-type and an empty request body; explicit JSON remains serialized; explicit null is rejected before transport.\n- bun install --force --frozen-lockfile\n- bun run test test/generated-command.test.ts\n- bun run generate:check\n- mise run check (19 files, 177 tests)\n\nFixes #52.\n\nNote: this independently edits the same pinned Effect patch as the custom-verb-path PR. If that lands first, rebase this PR and verify the combined patch.

Rationale: Generated public commands decode an omitted optional body as undefined, but the shared Effect HTTP client serialized that no-content branch as JSON. This made body-less worker-bootstrap requests fail server validation. Skip request-body encoding only when the endpoint explicitly permits HttpApiSchema.NoContent and the payload is undefined; explicit JSON remains encoded and null continues to fail input validation.

Rejected: Per-operation request construction would duplicate the generated client path and leave every other optional OpenAPI body broken. Treating all undefined payloads as absent would weaken required-body behavior.

Risk: This changes the pinned Effect patch shared with the custom-verb fix; the additions are independent HttpApiClient hunks and require rebase/combined-patch verification if that PR lands first.

Tested: bun install --force --frozen-lockfile; bun run test test/generated-command.test.ts; bun run generate:check; mise run check; git diff --check.
@robinbraemer
robinbraemer force-pushed the codex/fix-optional-generated-body branch from a8e036e to 0e3ab08 Compare September 10, 2026 14:19
@robinbraemer
robinbraemer merged commit 1614694 into main Sep 10, 2026
7 checks passed
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