Skip to content

fix: recursively enforce required properties in OpenAI tool schemas#1710

Merged
dgageot merged 2 commits intodocker:mainfrom
dgageot:mcp-openai
Feb 13, 2026
Merged

fix: recursively enforce required properties in OpenAI tool schemas#1710
dgageot merged 2 commits intodocker:mainfrom
dgageot:mcp-openai

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 12, 2026

Fixes Chrome MCP with openai 5.2

@dgageot dgageot requested a review from a team as a code owner February 12, 2026 14:40
rumpl
rumpl previously approved these changes Feb 12, 2026
Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

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

sure

Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Approved

This PR successfully refactors the schema processing to recursively enforce required properties throughout nested JSON schemas, which fixes the Chrome MCP integration with OpenAI 5.2.

Changes Reviewed

New walkSchema function:

  • Cleanly abstracts the recursive traversal logic
  • Properly handles properties, anyOf/oneOf/allOf variants, and array items
  • Uses safe comma-ok idiom for all type assertions
  • No risk of infinite recursion (JSON structures are acyclic)

Refactored makeAllRequired:

  • Now processes all nested schema nodes, not just top-level
  • Correctly marks newly-required properties as nullable
  • Maintains sorted order for deterministic output

Refactored removeFormatFields:

  • Simplified to use walkSchema helper
  • More maintainable and consistent

Testing

Comprehensive test coverage added for:

  • anyOf variants with nested required fields ✓
  • Nested object properties ✓
  • Array items with required fields ✓

The refactoring is sound and well-tested. No issues found.

Signed-off-by: David Gageot <david.gageot@docker.com>
Fixes Chrome MCP with openai 5.2

Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot dgageot merged commit 1577440 into docker:main Feb 13, 2026
5 checks passed
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.

2 participants