{"record":{"id":"31c4caa826a50609","repo":"ToolJet/ToolJet","slug":"step-is-required-for-range-query","errorCode":null,"errorMessage":"Step is required for range query","messagePattern":"Step is required for range query","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"marketplace/plugins/prometheus/lib/query_operations.ts","lineNumber":43,"sourceCode":"    return await makePostRequest(sourceOptions, endpoint, params);\n  }\n}\n\nexport async function rangeQuery(sourceOptions: SourceOptions, queryOptions: QueryOptions): Promise<QueryResult> {\n  if (!sourceOptions.server_url) {\n    throw new Error('Server URL is required');\n  }\n  if (!queryOptions.rq_query) {\n    throw new Error('Query is required for range query');\n  }\n  if (!queryOptions.rq_start) {\n    throw new Error('Start time is required for range query');\n  }\n  if (!queryOptions.rq_end) {\n    throw new Error('End time is required for range query');\n  }\n  if (!queryOptions.rq_step) {\n    throw new Error('Step is required for range query');\n  }\n\n  const requestMethod = queryOptions.rq_requestMethod || 'get';\n  const endpoint = `${sourceOptions.server_url}/api/v1/query_range`;\n  const params = {\n    query: queryOptions.rq_query,\n    start: queryOptions.rq_start,\n    end: queryOptions.rq_end,\n    step: queryOptions.rq_step,\n    timeout: queryOptions.rq_timeout,\n    limit: queryOptions.rq_limit,\n  };\n\n  if (requestMethod === 'get') {\n    return await makeGetRequest(sourceOptions, endpoint, params);\n  } else {\n    return await makePostRequest(sourceOptions, endpoint, params);\n  }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/marketplace/plugins/prometheus/lib/query_operations.ts#L25-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Default the step input to a reasonable value (e.g. '1m') so the query always has resolution.","Validate rq_step is a non-empty string before calling rangeQuery."],"exampleFix":"// before\nconst result = await rangeQuery(sourceOptions, queryOptions);\n\n// after\nif (!queryOptions.rq_step) {\n  throw new Error('rq_step is required (e.g. \"15s\", \"1m\").');\n}\nconst result = await rangeQuery(sourceOptions, queryOptions);","handlingStrategy":"validation","validationCode":"function assertRangeQueryInput(q: { rq_query?: string; rq_start?: string; rq_end?: string; rq_step?: string }) {\n  if (!q?.rq_step || !q.rq_step.trim()) throw new Error('rq_step is required for range query.');\n}","typeGuard":"const hasRqStep = (q: unknown): q is { rq_step: string } =>\n  typeof q === 'object' && q !== null && typeof (q as any).rq_step === 'string' && (q as any).rq_step.trim() !== '';","tryCatchPattern":"try { return await rangeQuery(sourceOptions, queryOptions); }\ncatch (e) { if (e instanceof Error && /Step is required/.test(e.message)) { /* default step '1m' */ } throw e; }","preventionTips":["Default the step input to a reasonable duration (e.g. '1m') so a range always has resolution.","Validate step is a non-empty duration string before running.","Warn the user when step is large relative to the range (few samples)."],"tags":["prometheus","validation","promql","typescript","required-field"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}