{"record":{"id":"d85a2a3aa73efa74","repo":"SigNoz/signoz","slug":"step-param-is-not-in-correct-format","errorCode":null,"errorMessage":"step param is not in correct format","messagePattern":"step param is not in correct format","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":196,"sourceCode":"}\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}\n\n\treturn &getUsageParams, nil\n\n}","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L178-L214","documentation":"The usage endpoint parses step with strconv.Atoi, so it must be a plain base-10 integer of seconds. Duration strings like 60s, floats like 1.5, or non-numeric values fail parsing.","triggerScenarios":"GET /api/v1/usage?step=60s, ?step=1h, ?step=1.5, or ?step=five — anything not parseable by Go's Atoi.","commonSituations":"Reusing Prometheus-style duration strings (15s, 1h) on the usage endpoint; passing milliseconds (3600000) thinking it's a duration format; locale-formatted numbers.","solutions":["Send step as an integer number of seconds: 60 not 60s, 3600 not 1h","Convert durations client-side before building the URL: seconds = duration.Seconds() as int","Verify no whitespace or units sneak into the value"],"exampleFix":"// before\nparams.Set(\"step\", \"1h\")\n// after\nparams.Set(\"step\", \"3600\")","handlingStrategy":"validation","validationCode":"stepStr := strconv.Itoa(int(d.Seconds())) // not d.String()\nq.Set(\"step\", stepStr)\nif _, err := strconv.Atoi(stepStr); err != nil {\n    return errors.New(\"step must be integer seconds\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass duration strings (1h, 15s) to this endpoint","Centralize param serialization in one helper","Fuzz/property-test param building with random durations"],"tags":["validation","usage","parsing","step"],"backgroundTag":"invalid-parameter-format","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}