ToolJet/ToolJet · error · Error

Step is required for range query

Error message

Step is required for range query

What it means

Thrown by Prometheus rangeQuery() as a plain Error when queryOptions.rq_step is falsy. rq_step is the `step` parameter of /api/v1/query_range, the resolution interval between samples. Without a step Prometheus cannot discretize the range.

Source

Thrown at marketplace/plugins/prometheus/lib/query_operations.ts:43

    return await makePostRequest(sourceOptions, endpoint, params);
  }
}

export async function rangeQuery(sourceOptions: SourceOptions, queryOptions: QueryOptions): Promise<QueryResult> {
  if (!sourceOptions.server_url) {
    throw new Error('Server URL is required');
  }
  if (!queryOptions.rq_query) {
    throw new Error('Query is required for range query');
  }
  if (!queryOptions.rq_start) {
    throw new Error('Start time is required for range query');
  }
  if (!queryOptions.rq_end) {
    throw new Error('End time is required for range query');
  }
  if (!queryOptions.rq_step) {
    throw new Error('Step is required for range query');
  }

  const requestMethod = queryOptions.rq_requestMethod || 'get';
  const endpoint = `${sourceOptions.server_url}/api/v1/query_range`;
  const params = {
    query: queryOptions.rq_query,
    start: queryOptions.rq_start,
    end: queryOptions.rq_end,
    step: queryOptions.rq_step,
    timeout: queryOptions.rq_timeout,
    limit: queryOptions.rq_limit,
  };

  if (requestMethod === 'get') {
    return await makeGetRequest(sourceOptions, endpoint, params);
  } else {
    return await makePostRequest(sourceOptions, endpoint, params);
  }

View on GitHub (pinned to 20602a8e10)

Solutions

  1. Supply rq_step as a PromQL duration string (e.g. '15s', '1m', '5m') or a number of seconds in the range query's Step field.
  2. Default the step input to a reasonable value (e.g. '1m') so the query always has resolution.
  3. Validate rq_step is a non-empty string before calling rangeQuery.

Example fix

// before
const result = await rangeQuery(sourceOptions, queryOptions);

// after
if (!queryOptions.rq_step) {
  throw new Error('rq_step is required (e.g. "15s", "1m").');
}
const result = await rangeQuery(sourceOptions, queryOptions);
Defensive patterns

Strategy: validation

Validate before calling

function assertRangeQueryInput(q: { rq_query?: string; rq_start?: string; rq_end?: string; rq_step?: string }) {
  if (!q?.rq_step || !q.rq_step.trim()) throw new Error('rq_step is required for range query.');
}

Type guard

const hasRqStep = (q: unknown): q is { rq_step: string } =>
  typeof q === 'object' && q !== null && typeof (q as any).rq_step === 'string' && (q as any).rq_step.trim() !== '';

Try / catch

try { return await rangeQuery(sourceOptions, queryOptions); }
catch (e) { if (e instanceof Error && /Step is required/.test(e.message)) { /* default step '1m' */ } throw e; }

Prevention

When it happens

Trigger: Calling rangeQuery with rq_step undefined/empty. The step/duration input was not supplied, or a duration string (e.g. '15s', '1m') resolved to empty.

Common situations: Step field left blank in the range-query form; a duration selector component bound to rq_step had no default; the user expected a default step but the plugin requires it explicitly.

Related errors


AI-assisted analysis of ToolJet/ToolJet@20602a8e10 (2026-08-13). Data as JSON: /api/errors/31c4caa826a50609. Report an issue: GitHub.