Skip to content

fix(parse): reject unrepresentable dynamic object schemas - #1818

Open
uuzzrm wants to merge 1 commit into
anthropics:mainfrom
uuzzrm:codex/reject-unrepresentable-object-schema
Open

fix(parse): reject unrepresentable dynamic object schemas#1818
uuzzrm wants to merge 1 commit into
anthropics:mainfrom
uuzzrm:codex/reject-unrepresentable-object-schema

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 10, 2026

Copy link
Copy Markdown

Summary

Fixes #1817.

When an object schema uses patternProperties, propertyNames, or unevaluatedProperties without explicit properties, the structured-output schema transformer previously discarded the dynamic-key rule and emitted an object with no properties and additionalProperties: false. That silently made every non-empty value invalid.

This change raises a clear ValueError for those unrepresentable shapes instead of sending an unsatisfiable schema. Objects that already have explicit properties keep their existing behavior; unsupported dynamic-key constraints remain in the description as before.

Tests

  • UV_PYTHON='>=3.9,<3.10' ./scripts/test tests/lib/_parse/test_transform.py
    • Pydantic v2: 18 passed
    • Pydantic v1: 18 passed
    • MCP v2: skipped because MCP 2 requires Python 3.10+
  • UV_PYTHON='>=3.10,<3.11' ./scripts/test tests/lib/_parse/test_transform.py
    • Pydantic v2: 18 passed
    • Pydantic v1: 18 passed
    • MCP v2: 39 passed
  • uv run pyright src/anthropic/lib/_parse/_transform.py: 0 errors
  • uv run ruff check src/anthropic/lib/_parse/_transform.py tests/lib/_parse/test_transform.py: passed
  • uv run ruff format --check src/anthropic/lib/_parse/_transform.py tests/lib/_parse/test_transform.py: passed

@uuzzrm
uuzzrm requested a review from a team as a code owner August 10, 2026 05:18
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.

transform_schema empties a patternProperties map: field can only ever be {}

1 participant