Describe the bug
PydocHelper.generate_return_doc builds its sorted response list with
sorted(responses.items(), key=lambda item: int(item[0])). OpenAPI 3.x allows
non-numeric keys in the Responses Object — default and the range patterns
1XX/2XX/3XX/4XX/5XX. When any of those keys is present, int(item[0])
raises ValueError, so generating a tool from an otherwise valid OpenAPI spec
crashes.
To Reproduce
from fastapi.openapi.models import Response, Schema, MediaType
from google.adk.tools.openapi_tool.common.common import PydocHelper
responses = {
"200": Response(description="OK", content={"application/json": MediaType(schema=Schema(type="string"))}),
"default": Response(description="Error response"),
}
PydocHelper.generate_return_doc(responses)
# ValueError: invalid literal for int() with base 10: 'default'
Expected behavior
Non-numeric response keys should be ignored for return-type hinting (the code
already keeps only 2xx responses with content on the very next line), so the
function should return the doc for the 200 response instead of crashing.
Desktop
- google-adk 2.1.0 and later; still present on
main as of 2026-06-10
Additional context
operation_parser already filters startswith('2') before consuming the keys;
applying the same guard here keeps the two paths consistent.
Describe the bug
PydocHelper.generate_return_docbuilds its sorted response list withsorted(responses.items(), key=lambda item: int(item[0])). OpenAPI 3.x allowsnon-numeric keys in the Responses Object —
defaultand the range patterns1XX/2XX/3XX/4XX/5XX. When any of those keys is present,int(item[0])raises
ValueError, so generating a tool from an otherwise valid OpenAPI speccrashes.
To Reproduce
Expected behavior
Non-numeric response keys should be ignored for return-type hinting (the code
already keeps only
2xxresponses with content on the very next line), so thefunction should return the doc for the
200response instead of crashing.Desktop
mainas of 2026-06-10Additional context
operation_parseralready filtersstartswith('2')before consuming the keys;applying the same guard here keeps the two paths consistent.