#18047·langfuse

bug: manual time edits can commit an inverted date range

Author: dakjdakdCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbugfeat-dashboard

Prerequisites

  • I have searched the existing date-picker, dashboard-filter, and time-range issues and pull requests for this behavior.
  • This is a bug report, not a question about date-range syntax.

Describe the bug

The shared time-range picker allows the user to edit the start and end times independently, but it validates only the maximum duration. A range where the end is earlier than the start has a negative duration, so it passes that check.

The two affected paths are:

  • TimeRangePicker, used by dashboards, the project home page, score analytics, and the events table;
  • DatePickerWithRange, used by widget configuration and dashboard date-range editing.

Both callbacks update the selected range after changing one boundary. isRangeWithinMaxDuration currently returns true for an inverted range whenever the configured maximum is large enough, or whenever no maximum is configured.

The range is then serialized by useGlobalDateRange and written to the URL or the project default. rangeFromString later rejects from > to and falls back to a named preset. The user therefore loses the range they just selected without an explanation.

Steps to reproduce

  1. Open a dashboard with a custom time range.
  2. Select a single day so that both boundaries are on the same date.
  3. Set the end time to 01:00.
  4. Set the start time to 23:00.
  5. Close and reopen the picker, or navigate to a view that reads the range from the URL.

The picker accepts the edit, but the serialized range is inverted and the next read resolves it to the fallback preset instead of preserving the selected values.

Expected behavior

A manual edit that would make from later than to should be rejected before it updates component state, the URL, the project default, or any query.

The last valid range should remain visible so the user can correct the boundary. Valid ranges should keep the existing maximum-duration behavior.

Impact

This affects every view that uses the shared time-range picker and is most confusing for same-day ranges, where changing the hour is expected to be a local adjustment. Dashboard and widget queries can appear to reset to a different period, and shared links can contain a value that the application immediately replaces with a preset.

Proposed fix

Make isRangeWithinMaxDuration reject to < from independently of the optional maximum duration. Use that shared predicate before committing manual start and end time edits in both picker components.

Add regression coverage for:

  • inverted ranges with a configured maximum duration;
  • inverted ranges without a maximum duration;
  • start-time edits crossing the end boundary;
  • end-time edits crossing the start boundary;
  • the last valid range remaining unchanged when an edit is rejected.

Relevant code

  • web/src/components/date-picker.tsx — isRangeWithinMaxDuration, TimeRangePicker, and DatePickerWithRange.
  • web/src/features/global-time-range/useGlobalDateRange.ts — URL and project-default persistence.
  • web/src/utils/date-range-utils.ts — custom-range parsing and validation.

Actual versus expected range

The manual edit produces a range like:

from: 2026-06-10T23:00:00
 to: 2026-06-10T01:00:00

The picker accepts it because the duration is negative. When the value is read back from the URL, rangeFromString rejects the ordering and returns the view's fallback preset. The expected result is that the edit is not committed and the previous valid range remains selected.

Environment

  • Langfuse main at 81e065bb0
  • Affected surfaces: dashboard, project home, score analytics, events, and widget date-range controls
  • Reproduction requires only the web date-picker interaction; no external provider or database data is needed