fix(cli): omit absent optional request bodies - #57
Merged
Merged
Conversation
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
force-pushed
the
codex/fix-optional-generated-body
branch
from
September 10, 2026 14:19
a8e036e to
0e3ab08
Compare
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.
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 allowsHttpApiSchema.NoContentand the generated payload isundefined.\n- Keep explicit JSON body values unchanged.\n- Reject explicitnullduring generated input decoding before transport.\n\n## Verification\n\n- RED: intercepted generated command transport receivedapplication/jsonfor an omitted optional body.\n- GREEN: omitted body has nocontent-typeand 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.