Skip to content

fix: replace tuple[str, int] with list[int | str] in ports schema#48

Open
oijkn wants to merge 1 commit intockreiling:mainfrom
oijkn:fix/ports-tuple-invalid-json-schema
Open

fix: replace tuple[str, int] with list[int | str] in ports schema#48
oijkn wants to merge 1 commit intockreiling:mainfrom
oijkn:fix/ports-tuple-invalid-json-schema

Conversation

@oijkn
Copy link

@oijkn oijkn commented Mar 19, 2026

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.

   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.
Copilot AI review requested due to automatic review settings March 19, 2026 14:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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] with list[int | str] in the ports union type to ensure valid JSON Schema (items present) for arrays.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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