Skip to content

Keep unparseable date values as raw text instead of crashing - #2665

Merged
kmcginnes merged 1 commit into
mainfrom
fix-unparseable-date-crash
Nov 24, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
fix-unparseable-date-crash

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

A date property whose value the browser can't parse became an invalid Date, and formatting it for display threw RangeError: Invalid time value, which crashed the graph view.

User-facing: A date value that can't be parsed now shows as its original text, and the graph view keeps working. Valid dates look the same as before.

One helper at the connector boundary owns the rule, so no invalid Date leaves the mappers:

/** Returns a valid Date, or the raw value unchanged when it doesn't parse. */
export function parseDate<T extends string | number>(raw: T): Date | T
 mapSparqlValueToScalar   (SPARQL xsd:date, xsd:dateTime)
 parseProperty, mapResults (Gremlin g:Date)
 mapApiProperties         (openCypher ISO datetime strings)
-  new Date(raw)
+  parseDate(raw)

Decisions:

  • Display: an unparseable date displays as the raw text the database returned.
  • Raw value kept: the mapper stores the original string (or the original number for an out-of-range Gremlin g:Date), so nothing is lost.
  • XSD date with a zone offset (1901-12-10+02:00) is kept as raw text rather than parsed by a custom XSD parser. The JS Date parser rejects that form, and the text already says what the value is.

Evidence

Before: mapSparqlValueToScalar returned an Invalid Date for xsd:date 1901-12-10+02:00 or 1955-00-00, and getDisplayValueForScalar threw on it.

After: new tests pass for each case:

parseDate("1901-12-10+02:00")      -> "1901-12-10+02:00"
parseDate("1955-00-00")            -> "1955-00-00"
parseDate(8.64e15 + 1)             -> 8.64e15 + 1
parseDate("2023-12-25T10:30:00Z")  -> Date (unchanged behavior)
getDisplayValueForScalar(parseDate("1955-00-00")) -> "1955-00-00"
mapSparqlValueToScalar / parseProperty / mapAnyValue -> raw value for unparseable dates

Agent-tested with the unit suite only; not checked live against a database.

Merge Danger

Door: two-way

Impact: minimal. Only values that used to become an invalid Date change type, from Date to their raw string or number. Valid dates map to the same Date as before.

Related


🤖 Written by an AI agent on my behalf.

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@kmcginnes
kmcginnes merged commit 7e5ea62 into main Nov 24, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the fix-unparseable-date-crash branch November 24, 2026 22:36
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.

Graph view crashes on a date property that can't be parsed

1 participant