Skip to content

Fix boolean property schemas in JSON Schema parsing#3785

Merged
jlowin merged 2 commits intomainfrom
fix/boolean-json-schema-properties
Apr 7, 2026
Merged

Fix boolean property schemas in JSON Schema parsing#3785
jlowin merged 2 commits intomainfrom
fix/boolean-json-schema-properties

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Apr 7, 2026

JSON Schema draft-06+ allows true and false as valid property schemas — true meaning "any value is valid" (equivalent to {}), false meaning "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_type crashes because it calls .get() on a bool.

The fix normalizes boolean schemas to {} before property processing and adds an early return in _schema_to_type for boolean inputs:

schema = {
    "type": "object",
    "properties": {
        "_ts": {"type": "integer"},
        "level": True,    # was crashing here
        "_app": True,
        "host": True,
    },
    "additionalProperties": True,
}
json_schema_to_type(schema)  # now works

Fixes #3783

JSON Schema draft-06+ allows `true` and `false` as valid property
schemas, meaning "any value valid" and "no value valid" respectively.
Fixes #3783.
@marvin-context-protocol marvin-context-protocol Bot added the bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. label Apr 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +323 to +324
if isinstance(schema, bool):
return Any
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.
@jlowin jlowin merged commit e5b9634 into main Apr 7, 2026
8 checks passed
@jlowin jlowin deleted the fix/boolean-json-schema-properties branch April 7, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON schema parsing does not handle boolean true/false as a property schema

1 participant