Skip to content

openapi: encode non-JSON request bodies correctly - #352

Merged
RhysSullivan merged 2 commits into
mainfrom
rs/openapi-encode-non-json-bodies
Apr 20, 2026
Merged

RhysSullivan merged 2 commits into
mainfrom
rs/openapi-encode-non-json-bodies

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Summary

  • The invoke path had only two body branches — JSON, or String(bodyValue) with the spec's content-type. For an object body + a non-JSON content-type we shipped the literal string [object Object] on the wire, which servers reject or hold open waiting for valid framing (the "hung request" reports from Affinity).
  • Dispatch on declared content-type: application/x-www-form-urlencoded → bodyUrlParams, multipart/form-data → bodyFormDataRecord (Effect picks the boundary), pre-serialized strings pass through unchanged, unknown non-JSON content-types fall back to JSON.stringify instead of [object Object].
  • New test form-urlencoded-body.test.ts stands up a raw node http echo server, registers a hand-authored spec with a form-urlencoded POST, invokes it with an object body, and asserts the bytes on the wire are properly URL-encoded.

Test plan

  • bunx vitest run src/sdk/form-urlencoded-body.test.ts — passes
  • Full openapi plugin suite — 37/37 green

The invoke path previously had only two branches for request bodies —
JSON, or `String(bodyValue)` with whatever content-type the spec
declared. For an object body that meant shipping the literal string
`[object Object]` on the wire with a content-type like
`application/x-www-form-urlencoded`, which servers reject or hang on
waiting for valid framing.

Dispatch on the declared content-type instead: form-urlencoded uses
`bodyUrlParams`, multipart uses `bodyFormDataRecord` (Effect picks the
boundary), pre-serialized strings pass through, and anything unknown
falls back to `JSON.stringify` rather than `[object Object]`.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud ec2ebb0 Apr 20 2026, 09:33 PM

@pkg-pr-new

pkg-pr-new Bot commented Apr 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor/sdk

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/sdk@352

@executor/plugin-file-secrets

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-file-secrets@352

@executor/plugin-google-discovery

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-google-discovery@352

@executor/plugin-graphql

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-graphql@352

@executor/plugin-keychain

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-keychain@352

@executor/plugin-mcp

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-mcp@352

@executor/plugin-oauth2

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-oauth2@352

@executor/plugin-onepassword

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-onepassword@352

@executor/plugin-openapi

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-openapi@352

@executor/plugin-workos-vault

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-workos-vault@352

executor

npm i https://pkg.pr.new/RhysSullivan/executor@352

commit: ec2ebb0

@RhysSullivan
RhysSullivan merged commit 7909ef4 into main Apr 20, 2026
9 checks passed
RhysSullivan added a commit that referenced this pull request May 31, 2026
…bodies

openapi: encode non-JSON request bodies correctly
@RhysSullivan
RhysSullivan deleted the rs/openapi-encode-non-json-bodies branch June 11, 2026 08:01
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