#1054·vanna

JSON serialization nug

Author: CellMookCreated Dec 11, 2025Updated Feb 17, 2026
Labelsbug

Describe the bug The application crashes during JSON serialization of a response chunk in the FastAPI route /generate. The error occurs because a float value is being passed where an integer is expected during Pydantic model serialization.

To Reproduce Steps to reproduce the behavior:

  1. Start the Vanna server using python app.py
  2. Send a request to the /generate endpoint (e.g., via frontend or curl) that triggers streaming response generation
  3. Observe the server logs
  4. See the PydanticSerializationError with message: 'float' object cannot be interpreted as an integer

Expected behavior The server should successfully serialize and stream the response chunks without crashing, even if numeric fields contain float values that are intended to be integers (or handle such cases gracefully).

Error logs/Screenshots text Traceback (most recent call last): File "/root/miniconda3/envs/vanna/lib/python3.12/site-packages/vanna/servers/fastapi/routes.py", line 58, in generate chunk_json = chunk.model_dump_json() ^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda3/envs/vanna/lib/python3.12/site-packages/pydantic/main.py", line 528, in model_dump_json return self.pydantic_serializer.to_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.PydanticSerializationError: Error serializing to JSON: TypeError: 'float' object cannot be interpreted as an integer

Desktop (please complete the following information): OS: Ubuntu Version: 20.04 Python: 3.12 Vanna: 2.8.0

Additional context The issue likely stems from a Pydantic model field defined as int that receives a float value (e.g., 1.0 instead of 1) during runtime—possibly from LLM output parsing or intermediate data processing. This causes serialization to fail because Pydantic’s strict mode (or underlying JSON encoder) does not auto-convert floats to ints. A fix may involve validating/casting numeric values before assigning them to integer fields, or relaxing field types if appropriate.