{"record":{"id":"7bc0578358266728","repo":"SigNoz/signoz","slug":"step-param-missing-in-query","errorCode":null,"errorMessage":"step param missing in query","messagePattern":"step param missing in query","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":192,"sourceCode":"\t\tStats: r.FormValue(\"stats\"),\n\t}\n\n\treturn &queryRangeParams, nil\n}\n\nfunc parseGetUsageRequest(r *http.Request) (*model.GetUsageParams, error) {\n\tstartTime, err := parseTime(\"start\", r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tendTime, err := parseTime(\"end\", r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstepStr := r.URL.Query().Get(\"step\")\n\tif len(stepStr) == 0 {\n\t\treturn nil, errors.New(\"step param missing in query\")\n\t}\n\tstepInt, err := strconv.Atoi(stepStr)\n\tif err != nil {\n\t\treturn nil, errors.New(\"step param is not in correct format\")\n\t}\n\n\tserviceName := r.URL.Query().Get(\"service\")\n\tstepHour := stepInt / 3600\n\n\tgetUsageParams := model.GetUsageParams{\n\t\tStartTime:   startTime.Format(time.RFC3339Nano),\n\t\tEndTime:     endTime.Format(time.RFC3339Nano),\n\t\tStart:       startTime,\n\t\tEnd:         endTime,\n\t\tServiceName: serviceName,\n\t\tPeriod:      fmt.Sprintf(\"PT%dH\", stepHour),\n\t\tStepHour:    stepHour,\n\t}","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L174-L210","documentation":"The usage endpoint parser requires a step query parameter expressed in seconds. If the step parameter is absent or empty, the request is rejected before usage aggregation runs.","triggerScenarios":"GET to the usage API without ?step=... (e.g. /api/v1/usage?step=86400 missing the parameter entirely), or step= with an empty value.","commonSituations":"Clients copying example URLs that omit step; conditional parameter building in code that skips step for 'all time' usage; URL-encoding bugs stripping empty params.","solutions":["Add step in seconds, e.g. ?step=3600 (hourly) or ?step=86400 (daily)","Audit client code that conditionally appends query params and ensure step is always set","Check the final constructed URL in logs to confirm the parameter is present"],"exampleFix":"// before\nreq := \"/api/v1/usage?service=frontend\"\n// after\nreq := \"/api/v1/usage?service=frontend&step=3600\"","handlingStrategy":"validation","validationCode":"if step == 0 {\n    step = 3600\n}\nq := url.Values{}\nq.Set(\"step\", strconv.Itoa(step))\nresp, err := http.Get(baseURL + \"/api/v1/usage?\" + q.Encode())","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make step a required field in client wrappers with a default","Log the final request URL to catch missing params","Write integration tests asserting required params are sent"],"tags":["validation","usage","api-request","missing-param"],"backgroundTag":"missing-required-query-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}