Langflow is a powerful tool for building and deploying AI-powered agents and workflows.
fix: Postgres JSON column fails with "Token NaN is invalid" when Agent stores message (psycopg InvalidTextRepresentation) (#11977)
* Refactor message model and validation methods
* [autofix.ci] apply automated fixes
* fix: address reviewer feedback on NaN sanitization PR
- Remove broken else branch in from_message that called file.path on str
(fixes AttributeError when message.files contains plain strings)
- Restore # type: ignore comments for SQLModel/mypy compatibility
- Move import math to module level instead of inside method
- Add TestSanitizeJson with 13 tests covering nan/inf/nested/Decimal cases
* test: actually inject float('inf') in content_blocks test
TextContent.duration is int | None so Pydantic rejects float('inf')
at construction. Use a raw dict to bypass validation and genuinely
exercise the _sanitize_json path, then assert duration is None after
sanitization and the full JSON round-trip produces no NaN/Inf values.
* fix: resolve all Ruff CI lint errors
model.py:
- EM101/TRY003: assign exception messages to variables before raising
test_messages.py:
- D205: add blank line between docstring summary and description
- FBT003: avoid boolean positional arg by assigning to variable first
- PLW0177: replace != float('nan') with math.isnan()
* fix: D415 docstring period and I001 import sort
* style: fix comment spacing (2 spaces before inline comment)
* refactor: address maintainer feedback on NaN sanitization
- Use math.isfinite() for cleaner NaN/Inf checks
- Add docstring to _sanitize_json explaining PostgreSQL jsonb constraints
- Document redundant sanitization in serializer as a defensive measure
- Simplify NaN assertion in properties test for better clarity
* fix: remove unused math import in test
* style: match CI formatting after import removal
* fix: preserve string file paths in mixed lists
Corrected regression where string paths were lost if a message
contained both string paths and Image objects. Updated the
corresponding backend test to assert preservation of mixed lists.
* fix: relocate tests to unit and fix NaN properties validation test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> A
Aryaman Sinha committed
7838d0d282cd50065c02579777ef23328aa15086
Parent: 73b6612
Committed by GitHub <[email protected]>
on 3/13/2026, 1:59:17 PM