fix(engine): clamp extreme historical dates to valid Python datetime range - #3403
Closed
handnewb wants to merge 1 commit into
Closed
fix(engine): clamp extreme historical dates to valid Python datetime range#3403handnewb wants to merge 1 commit into
handnewb wants to merge 1 commit into
Conversation
handnewb
force-pushed
the
fix/safe-date-clamping-extreme-years
branch
from
August 11, 2026 21:24
552ceb1 to
a17ff1e
Compare
…range Stored facts can carry BC-era dates or far-future projections that survive database ingestion but crash datetime.fromisoformat() with 'year N is out of range'. This poisons the entire recall / consolidation path for the affected bank, since the failure is deterministic. Changes: - consolidator.py: new _safe_fromisoformat() wrapper used by _as_dt() in the consolidation date-comparison path. Years < 1 clamp to year 1; years > 9999 clamp to year 9999, preserving the temporal signal (very old / very new) while preventing a crash. - memory_engine.py: same clamping logic added to _parse_edit_date() for the memory-unit edit path. Closes vectorize-io#3217.
handnewb
force-pushed
the
fix/safe-date-clamping-extreme-years
branch
from
August 11, 2026 21:28
a17ff1e to
cebb7ee
Compare
Collaborator
|
Closing in favor of #3413, which fixes the actual mechanism. The crash isn't |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3217: Stored facts can carry BC-era dates (e.g., year -534) or far-future projections that survive database ingestion but crash
datetime.fromisoformat()withValueError: year N is out of range. This poisons the entire recall/consolidation path for the affected bank — the failure is deterministic and retries don't help.Root Cause
datetime.fromisoformat()accepts only years 1–9999. Dates outside this range pass through PostgreSQL storage (which accepts any ISO 8601 string) but crash when the consolidation engine or memory-edit path tries to parse them.Changes
consolidator.py— consolidation date comparisonsNew
_safe_fromisoformat()wrapper used by_as_dt():datetime(1, 1, 1)datetime(9999, 12, 31, 23, 59, 59)memory_engine.py— memory-unit edit pathSame clamping logic added to
_parse_edit_date()with an inline try/except + regex fallback.Impact