Fix boolean property schemas in JSON Schema parsing#3785
Conversation
JSON Schema draft-06+ allows `true` and `false` as valid property schemas, meaning "any value valid" and "no value valid" respectively. Fixes #3783.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff8872f2c9
ℹ️ 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".
| if isinstance(schema, bool): | ||
| return Any |
There was a problem hiding this comment.
Enforce
false boolean schemas as unsatisfiable
_schema_to_type currently maps both boolean schemas to Any, but in JSON Schema only true is equivalent to an unconstrained schema; false must reject every value. With this implementation, payloads that should fail (for example an object with a property schema of false) are now accepted, so schema-derived validation can silently pass invalid data. Please branch False to an unsatisfiable representation/validator instead of returning Any.
Useful? React with 👍 / 👎.
`true` returns Any (any value valid), but `false` now returns an unsatisfiable type that rejects all values during Pydantic validation.
JSON Schema draft-06+ allows
trueandfalseas valid property schemas —truemeaning "any value is valid" (equivalent to{}),falsemeaning "no value is valid." When a tool's output schema uses boolean property schemas (common in APIs that define loose/catch-all fields),json_schema_to_typecrashes because it calls.get()on abool.The fix normalizes boolean schemas to
{}before property processing and adds an early return in_schema_to_typefor boolean inputs:Fixes #3783