Repository navigation
fix(openapi): JSON-encode object form fields in urlencoded request bodies - #5851
Merged
zzstoatzz merged 5 commits intoNov 10, 2026
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d6787f0fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Per the OAS Encoding Object, object properties default to contentType application/json. Passing them straight to httpx data= sent Python repr instead, with nested None rendered as None. Serialize object and array-of-object properties with json.dumps, honor explicit encoding contentType overrides, and keep primitive and array-of-primitive form encoding unchanged.
Recurse allOf/anyOf/oneOf and accept type lists when detecting array-of-object properties, so pydantic union schemas such as list[Model] | None JSON-encode their values. Fall back to the body schema's additionalProperties for undeclared form names so object map values are JSON-encoded instead of Python repr.
Form-urlencoded serialization selected any composition alternative that described an object array, so a oneOf/anyOf of array<object> and array<string> JSON-encoded a scalar list into one field instead of letting httpx repeat the key. Evaluate array branches against the runtime items so only a matching object branch is JSON-encoded. Resolve $refs with an active-reference set threaded through composition traversal; mutually recursive component graphs (A allOf $ref B, B starts with $ref A) previously recursed until RecursionError at request time. Cyclic branches are skipped, and the remaining branches still determine serialization.
BlueX888
force-pushed
the
fix/openapi-form-urlencoded-body
branch
from
October 19, 2026 17:37
8d6787f to
d40d5a8
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
8 of 9 tasks
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.
Closes #5850
Description
application/x-www-form-urlencodedrequest bodies sent object-typed properties as Pythonrepr(filter={'name': 'alice', 'age': 30}) and nestedNoneas the literalNone; per-propertyencodingoverrides were also ignored. Per the OAS Encoding Object, object properties default tocontentType: application/json, so these values must be JSON-encoded before form encoding. String arrays already repeated correctly.What changed
RequestDirector.buildnow builds urlencoded form data per property instead of handing the dict to httpx. Object-typed values and arrays of objects are serialized withjson.dumps(..., allow_nan=False)(nestedNonebecomesnull); explicitencoding.<prop>.contentTypewins, and non-JSON explicit content types keep their declared form.tags=a&tags=bbehavior is unchanged.$ref/allOfand merges inline$defswith the route's request schemas.Contribution type
Bug fix verification
Test path:
tests/server/providers/openapi/test_object_request_bodies.py(fourteen tests, mock transport recordsrequest.content).Red at
adf90b66(implementation reverted, final tests applied): 12 failed, 35 passed, all assertion failures, no collection errors (object inline/$ref, nested null, array of objects, explicit encoding, composed/union arrays of objects, and theadditionalPropertiesmap; the JSON-body control passes as expected).Green at the fix commit: 1717 passed, 1 skipped across
tests/server/providers/openapi/ tests/utilities/.Validation
uv run --isolated pytest tests/server/providers/openapi/ tests/utilities/ -q-> 1717 passed, 1 skippeduv run --isolated ruff checkandruff format --checkon the changed files -> cleanuv run --isolated ty check-> All checks passedAI assistance
Tool(s) used: Claude Code
How you used it: investigated from a verified reproduction, implemented the schema-aware form building and the regression tests.
Checklist
uv run prek run --all-filesand all checks pass (focused checks passed)Review follow-up
Codex review found two composition gaps, both fixed: a form property whose union includes both
array<object>andarray<string>now selects the branch matching the runtime value (scalar arrays stay repeated keys instead of being JSON-dumped by the unused object branch), and the schema traversal now carries an active-reference set so mutually recursive$ref/allOfgraphs cannot raiseRecursionError. Regression tests cover both.