grafana/grafana · error · Error

QuickRanges is not an array

Error message

QuickRanges is not an array

What it means

Thrown by validateDashboardSchemaV2 (transformSceneToSaveModelSchemaV2.ts:929) when timeSettings.quickRanges is present but not an array. quickRanges is an optional array of time-range preset definitions; a non-array aborts serialization. Only checked when the key is present and not undefined.

Source

Thrown at public/app/features/dashboard-scene/serialization/transformSceneToSaveModelSchemaV2.ts:929

  }

  // Optional time settings with defaults
  if (
    'autoRefreshIntervals' in timeSettings &&
    timeSettings.autoRefreshIntervals !== undefined &&
    !Array.isArray(timeSettings.autoRefreshIntervals)
  ) {
    throw new Error('AutoRefreshIntervals is not an array');
  }
  if ('timezone' in timeSettings && timeSettings.timezone !== undefined && typeof timeSettings.timezone !== 'string') {
    throw new Error('Timezone is not a string');
  }
  if (
    'quickRanges' in timeSettings &&
    timeSettings.quickRanges !== undefined &&
    !Array.isArray(timeSettings.quickRanges)
  ) {
    throw new Error('QuickRanges is not an array');
  }
  if ('weekStart' in timeSettings && timeSettings.weekStart !== undefined) {
    if (
      typeof timeSettings.weekStart !== 'string' ||
      !['saturday', 'sunday', 'monday'].includes(timeSettings.weekStart)
    ) {
      throw new Error('WeekStart should be one of "saturday", "sunday" or "monday"');
    }
  }
  if ('nowDelay' in timeSettings && timeSettings.nowDelay !== undefined && typeof timeSettings.nowDelay !== 'string') {
    throw new Error('NowDelay is not a string');
  }
  if (
    'fiscalYearStartMonth' in timeSettings &&
    timeSettings.fiscalYearStartMonth !== undefined &&
    typeof timeSettings.fiscalYearStartMonth !== 'number'
  ) {
    throw new Error('FiscalYearStartMonth is not a number');

View on GitHub (pinned to ae3104e369)

Solutions

  1. Wrap a single range in [ ] or coerce with Array.isArray(x) ? x : x == null ? undefined : [x].
  2. Omit the key when there are no quick ranges so the optional branch is skipped.

Example fix

// before
const ts = { ...timeSettings, quickRanges: source.defaultRange };
// after
const raw = source.defaultRange;
const ts = { ...timeSettings, quickRanges: raw == null ? undefined : Array.isArray(raw) ? raw : [raw] };
Defensive patterns

Strategy: validation

Validate before calling

if ('quickRanges' in (dash.timeSettings ?? {}) && dash.timeSettings.quickRanges !== undefined && !Array.isArray(dash.timeSettings.quickRanges)) {
  throw new Error('timeSettings.quickRanges must be an array');
}

Type guard

function isQuickRangeArray(v: unknown): v is unknown[] { return Array.isArray(v); }

Try / catch

try {
  validateDashboardSchemaV2(dash);
} catch (e) {
  if (String(e).includes('QuickRanges')) { const r = dash.timeSettings.quickRanges; dash.timeSettings.quickRanges = Array.isArray(r) ? r : r == null ? undefined : [r]; validateDashboardSchemaV2(dash); }
  else throw e;
}

Prevention

When it happens

Trigger: validateDashboardSchemaV2 gets timeSettings whose quickRanges is a single range object or a stringified blob instead of an array; typical from imported JSON or a producer that emitted a lone range.

Common situations: Migration from models storing a single quick range object; API payloads with malformed quickRanges; form input not wrapped in [ ].

Related errors


AI-assisted analysis of grafana/grafana@ae3104e369 (2026-08-12). Data as JSON: /api/errors/df1a04542be7a0c2. Report an issue: GitHub.