Coerce bare-int quantity/price to Decimal in enrich_parsed

GPT-4.1 cross-family review of the final PR diff (no BLOCK) flagged
residual type drift: parse_float=Decimal rules out floats on the LLM
path, but a bare JSON int survived as Python int. Coerce it so both
parse paths emit one canonical Decimal type.
This commit is contained in:
Adam Moussa 2026-07-16 16:16:58 -04:00
parent d247cd0cf7
commit 4bd426daf2
No known key found for this signature in database

View file

@ -373,6 +373,11 @@ def enrich_parsed(parsed: dict, s3_key: str, email_subject: str):
item[field] = Decimal(value.replace(",", "").strip())
except InvalidOperation:
pass
elif isinstance(value, (int, float)) and not isinstance(value, bool):
# parse_float=Decimal means floats can't occur on the LLM path,
# but a bare JSON int would slip through as Python int; coerce
# so both paths emit one canonical Decimal type (cross-review FIX).
item[field] = Decimal(str(value))
return parsed