{"record":{"id":"3b8695225bd11fef","repo":"SigNoz/signoz","slug":"zero-or-negative-query-resolution-step-widths-are","errorCode":null,"errorMessage":"zero or negative query resolution step widths are not accepted. Try a positive integer","messagePattern":"zero or negative query resolution step widths are not accepted\\. Try a positive integer","errorType":"validation","errorClass":"model.ApiError","httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":158,"sourceCode":"\tif err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\tend, err := parseMetricsTime(r.FormValue(\"end\"))\n\tif err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\tif end.Before(start) {\n\t\terr := errors.New(\"end timestamp must not be before start time\")\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\n\tstep, err := parseMetricsDuration(r.FormValue(\"step\"))\n\tif err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\n\tif step <= 0 {\n\t\terr := errors.New(\"zero or negative query resolution step widths are not accepted. Try a positive integer\")\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\n\t// For safety, limit the number of returned points per timeseries.\n\t// This is sufficient for 60s resolution for a week or 1h resolution for a year.\n\tif end.Sub(start)/step > 11000 {\n\t\terr := errors.New(\"exceeded maximum resolution of 11,000 points per timeseries. Try decreasing the query resolution (?step=XX)\")\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\n\tqueryRangeParams := model.QueryRangeParams{\n\t\tStart: start,\n\t\tEnd:   end,\n\t\tStep:  step,\n\t\tQuery: r.FormValue(\"query\"),\n\t\tStats: r.FormValue(\"stats\"),\n\t}\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L140-L176","documentation":"The range query parser requires a strictly positive step (query resolution). A step of zero or negative would cause infinite points or division issues, so SigNoz (like Prometheus) rejects it with ErrorBadData.","triggerScenarios":"GET query_range with step=0, step=-15s, or a step string that parses to a zero duration (e.g. step=0s), or omitting calculations that default step to 0 in generated URLs.","commonSituations":"Dashboards computing step as (end-start)/N where N=0 or integer division truncates to 0; hardcoded step variables; migrating queries from systems where step=0 meant auto.","solutions":["Set an explicit positive step such as step=15s or step=60","Fix client-side step math: guard against division by zero and round up to at least 1 second","Regenerate the URL after fixing the step parameter and retry"],"exampleFix":"// before\nstep := int(end.Sub(start).Seconds()) / numPoints // numPoints==0 -> 0\n// after\nif numPoints <= 0 {\n    numPoints = 100\n}\nstep := int(end.Sub(start).Seconds()) / numPoints\nif step < 1 {\n    step = 1\n}","handlingStrategy":"validation","validationCode":"stepDur, err := time.ParseDuration(stepStr)\nif err != nil || stepDur <= 0 {\n    stepDur = 60 * time.Second\n}\nresp, err := api.QueryRangeMetrics(ctx, start, end, stepDur, query)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default step to a sane positive value when user input is empty/zero","Compute step from window size rather than hardcoding","Reject step=0 early in UI controls"],"tags":["validation","metrics","step","time-range"],"backgroundTag":"invalid-query-step","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}