Skip to content

Pre-selected time filter options bypass duration validation #630

@cedricziel

Description

@cedricziel

Describe the bug

The time filter dropdown allows users to select pre-configured time ranges that exceed the maximum allowed duration constraint. When these pre-selected options are chosen, the application should either:

  1. Prevent selection and show a validation message, or
  2. Automatically constrain the selection to the maximum allowed duration

Current behavior:

  • Pre-selected time filter options (e.g., "Last 7 days", "Last 30 days") can be selected even when they exceed the maximum duration
  • No validation error is shown
  • User can proceed with an invalid time range

Expected behavior:

  • Time filter options that exceed maximum duration should be disabled or hidden
  • If selected, show clear validation feedback
  • Constrain selection to valid range automatically

Technical context

The time range validation in TracesByServiceScene.tsx (lines 108-115) clears selections that fall outside the time range:

// Clear selection if it's out of time range
if (selectionFrom && selectionFrom < timeRange.state.value.from.unix()) {
  this.setState({ selection: undefined });
}

However, this validation appears to run after selection, not before. The pre-selected time filter options may need validation at the point of rendering or selection.

Relevant files:

  • /src/components/Explore/TracesByService/TracesByServiceScene.tsx
  • /src/utils/dates.ts (duration formatting and calculations)
  • Time picker component (Grafana core)

Steps to reproduce

  1. Open Traces Drilldown
  2. Access the time filter dropdown
  3. Note the maximum allowed duration (if displayed)
  4. Select a pre-configured option that exceeds this limit (e.g., "Last 30 days")
  5. Observe that the selection is accepted without validation

Additional context

This creates a confusing user experience where the UI allows an action that will later fail or produce unexpected results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions