Skip to content

fix(gds21): coerce invalid GDS datetimes to epoch - #1

Merged
onefifth merged 3 commits into
fixesfrom
fix/gds-invalid-datetimes
Oct 7, 2026
Merged

onefifth merged 3 commits into
fixesfrom
fix/gds-invalid-datetimes

Conversation

@onefifth

@onefifth onefifth commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Why

GDS files with all-zero or otherwise invalid BGNLIB/BGNSTR timestamps made gds21 panic inside chrono. Geometry never reached the caller. Invalid dates now fall back to the Unix epoch so load can continue.

What changed

  • parse_datetimes uses from_ymd_opt / and_hms_opt and substitutes 1970-01-01 00:00:00 when a value is out of range.
  • A write/patch/reload regression asserts boundary geometry still parses when those date fields are zeroed.

Scope

  • Covers datetime parse only.
  • Leaves GdsDateTimes as required NaiveDateTime fields. Does not invent an unset/optional date API.

Tradeoffs

  • Rejecting the whole library on bad dates would still block useful geometry. Silent epoch fallback keeps load working and stays deterministic.

Blast Radius

  • Touches every GDS read path that hits BGNLIB or BGNSTR dates. Valid timestamps are unchanged. Invalid ones that used to panic now load with epoch metadata.

Verification

  • cargo test -p gds21 -- invalid_datetimes_preserve_geometry passes.
  • cargo test -p gds21 passes (11 tests).
  • ipviz cargo test --package gds --lib -- tests::test_gds against OneDieBad.gds passes.

onefifth and others added 3 commits October 7, 2026 21:41
Add a regression that zeroes library and struct date fields and
expects geometry to survive parse.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace panicking chrono date constructors in parse_datetimes with
fallible opts and fall back to 1970-01-01 so bad metadata cannot
abort library load.

Co-authored-by: Cursor <cursoragent@cursor.com>
@onefifth
onefifth merged commit cc746a7 into fixes Oct 7, 2026
2 of 10 checks passed
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.

1 participant