Skip to content

Enum of type: int: X not validating #2199

Open

Description

@alonahmias

Environment details

  • Programming language: python
  • OS: arch linux
  • Language runtime version: 3.13
  • Package version: 1.64.0

Steps to reproduce

from enum import IntEnum

from google import genai
from google.genai import types

1. Define an Integer-based Enum

class DaysEnum(IntEnum):
ONE = 1
FIVE = 5
TEN = 10

2. Define a Pydantic model using that Enum

def WeatherRequest(location: str, days: DaysEnum) -> str:
return f"Weather in {location} for {days} days"

def reproduce_error():
# Credentials aren't even needed to see the validation fail
# during schema transformation
client = genai.Client(api_key="DUMMY_KEY")

print("Attempting to use a tool with an IntEnum...")

try:
    # The crash happens when the SDK tries to convert the
    # Pydantic model into a Google API 'Schema' object.
    response = client.models.generate_content(
        model="gemini-3.1-flash-lite-preview",
        contents="What is the weather in London for 5 days?",
        config=types.GenerateContentConfig(tools=[WeatherRequest]),
    )
except Exception as e:
    print("\nCaught Expected Error:")
    print(f"{type(e).__name__}: {e}")

if name == "main":
reproduce_error()

The error:
*/.venv/lib/python3.13/site-packages/pydantic/main.py:464: UserWarning: Pydantic serializer warnings:
PydanticSerializationUnexpectedValue(Expected str - serialized value may not be as expected [field_name='enum', input_value=1, input_type=int])
PydanticSerializationUnexpectedValue(Expected str - serialized value may not be as expected [field_name='enum', input_value=5, input_type=int])
PydanticSerializationUnexpectedValue(Expected str - serialized value may not be as expected [field_name='enum', input_value=10, input_type=int])
return self.pydantic_serializer.to_python(

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Mar 22, 2026
  2. Venkaiahbabuneelam commented on Mar 31, 2026

    @Venkaiahbabuneelam

    Hi @alonahmias, Thanks for reaching out us!

    Thank you for bringing this to our attention. We truly appreciate you flagging this issue, we will file a bug internally.

    Thanks

  3. alonahmias commented on Apr 23, 2026

    @alonahmias
    Author

    @Venkaiahbabuneelam do you have any updates?

  4. alonahmias commented on Jun 14, 2026

    @alonahmias
    Author

    @Venkaiahbabuneelam any updates? because its really holding us back

  5. added 5 commits that reference this issue on Nov 5, 2026
    2c176d3
    74af11a
    2d3c348
    e965fb6
    65a4e34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions