Skip to content

Fix: coerce NaN to None for optional string fields in TransactionObject#147

Open
edbyford wants to merge 1 commit intojuftin:mainfrom
edbyford:fix/nan-optional-string-fields
Open

Fix: coerce NaN to None for optional string fields in TransactionObject#147
edbyford wants to merge 1 commit intojuftin:mainfrom
edbyford:fix/nan-optional-string-fields

Conversation

@edbyford
Copy link
Copy Markdown

Summary

  • Adds a field_validator to TransactionObject that coerces NaN float values to None for optional string fields (category_name, recurring_payee, recurring_cadence, recurring_type, recurring_currency, recurring_description)
  • When the Lunch Money API returns null for these fields, they can arrive as NaN floats (e.g. via pandas), causing Pydantic validation to fail with Input should be a valid string [type=string_type, input_value=nan, input_type=float]
  • Similar pattern to the fix applied in Assets Validation Error on Nulls in 'balance_as_of' field in Assets #113 for the Assets model

Fixes #146

Test plan

  • Run lunchable plugins primelunch against a Lunch Money account with uncategorised transactions or transactions without recurring fields
  • Verify transactions are fetched and matched without ValidationError

🤖 Generated with Claude Code

When the Lunch Money API returns null for optional string fields
(category_name, recurring_payee, recurring_cadence, recurring_type,
recurring_currency, recurring_description), these can arrive as NaN
floats rather than None, causing Pydantic validation to fail.

This adds a field_validator that coerces NaN values to None, similar
to the fix applied in juftin#113 for the Assets model.

Fixes juftin#146

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

ValidationError: TransactionObject fails on null recurring/category fields

1 participant