fix: replace tuple[str, int] with list[int | str] in ports schema#48
Open
oijkn wants to merge 1 commit intockreiling:mainfrom
Open
fix: replace tuple[str, int] with list[int | str] in ports schema#48oijkn wants to merge 1 commit intockreiling:mainfrom
oijkn wants to merge 1 commit intockreiling:mainfrom
Conversation
tuple[str, int] generates an array schema without an `items` field in
JSON Schema, which is invalid and causes a 400 error when the tool is
registered with AI APIs (e.g. OpenAI, Anthropic):
Invalid schema for function 'docker-create_container':
In context=('properties', 'ports', 'anyOf', '0', 'additionalProperties',
'anyOf', '2'), array schema missing items.
Replace with list[int | str] which correctly generates:
{"type": "array", "items": {"anyOf": [{"type": "integer"}, {"type": "string"}]}}
The Docker SDK accepts both int and "host_ip:port" string formats for
port bindings, so list[int | str] is semantically equivalent.
There was a problem hiding this comment.
Pull request overview
This PR fixes invalid JSON Schema generation for the CreateContainerInput.ports field so the create_container / run_container tools can be registered with AI function/tool APIs that reject array schemas missing an items definition.
Changes:
- Replace
tuple[str, int]withlist[int | str]in theportsunion type to ensure valid JSON Schema (itemspresent) for arrays.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
tuple[str, int] generates an array schema without an
itemsfield inJSON Schema, which is invalid and causes a 400 error when the tool is
registered with AI APIs (e.g. OpenAI, Anthropic):
Replace with list[int | str] which correctly generates:
{"type": "array", "items": {"anyOf": [{"type": "integer"}, {"type": "string"}]}}
The Docker SDK accepts both int and "host_ip:port" string formats for
port bindings, so list[int | str] is semantically equivalent.