Skip to content

fix: improve date handling by validating dates before formatting#1843

Merged
paustint merged 1 commit into
mainfrom
fix/better-date-handling
Jul 1, 2026
Merged

fix: improve date handling by validating dates before formatting#1843
paustint merged 1 commit into
mainfrom
fix/better-date-handling

Conversation

@paustint

@paustint paustint commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

there were a number of cases where dates would not be in a valid format and we would throw

Now we fallback to showing the raw value (e.g. in data table)

Resolves a number of betterstack issues

Copilot AI review requested due to automatic review settings July 1, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens date/time handling in UI formatting and edit-form transforms by validating parsed dates before formatting/converting, preventing runtime exceptions and falling back to raw values when inputs are not parseable.

Changes:

  • Add date-fns/isValid guards to prevent RangeError: Invalid time value when formatting invalid dates/times.
  • Fall back to the raw input string when parseISO/parse produces an invalid Date.
  • Add Vitest coverage for common valid/invalid date/time formatting scenarios in the data table formatters.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
libs/ui/src/lib/data-table/data-table-formatters.tsx Adds isValid checks before formatting/parsing to avoid throws and enable safe fallbacks.
libs/ui/src/lib/data-table/tests/data-table-formatters.spec.ts Adds regression/behavior tests for date/time formatter fallbacks and formatting shapes.
libs/shared/ui-core-shared/src/query-utils.ts Prevents transformEditForm from throwing on unparseable ISO strings by validating before converting.
libs/features/deploy/src/utils/deploy-metadata.utils.tsx Adds isValid checks in deployment metadata date formatting to avoid formatting invalid dates.

Comment thread libs/ui/src/lib/data-table/data-table-formatters.tsx Outdated
Comment thread libs/ui/src/lib/data-table/__tests__/data-table-formatters.spec.ts
there were a number of cases where dates would not be in a valid format and we would throw

Now we fallback to showing the raw value (e.g. in data table)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@paustint paustint merged commit 86339f7 into main Jul 1, 2026
9 checks passed
@paustint paustint deleted the fix/better-date-handling branch July 1, 2026 15:14
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.

2 participants