{"record":{"id":"87adf26ceaed7781","repo":"SigNoz/signoz","slug":"cannot-parse-the-request-body-v","errorCode":null,"errorMessage":"cannot parse the request body: %v","messagePattern":"cannot parse the request body: (.+?)","errorType":"http","errorClass":"model.ApiError","httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":761,"sourceCode":"\t\t\tIsSelectAll: true,\n\t\t\tFieldType:   \"scalar\",\n\t\t})\n\t}\n\ttransformer := chVariables.NewQueryTransformer(query, varsForTransform)\n\ttransformedQuery, err := transformer.Transform()\n\tif err != nil {\n\t\tslog.Warn(\"failed to transform clickhouse query\", \"query\", query, signozerrors.Attr(err))\n\t}\n\tslog.Info(\"transformed clickhouse query\", \"transformed_query\", transformedQuery, \"original_query\", query)\n}\n\nfunc ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiError) {\n\n\tvar queryRangeParams *v3.QueryRangeParamsV3\n\n\t// parse the request body\n\tif err := json.NewDecoder(r.Body).Decode(&queryRangeParams); err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf(\"cannot parse the request body: %v\", err)}\n\t}\n\n\t// sanitize the request body\n\tqueryRangeParams.CompositeQuery.Sanitize()\n\n\t// validate the request body\n\tif err := validateQueryRangeParamsV3(queryRangeParams); err != nil {\n\t\treturn nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}\n\t}\n\n\t// Clamp the top-level Step for PromQL\n\tif queryRangeParams.CompositeQuery.QueryType == v3.QueryTypePromQL {\n\t\tif minStep := common.MinAllowedStepInterval(queryRangeParams.Start, queryRangeParams.End); queryRangeParams.Step < minStep {\n\t\t\tqueryRangeParams.Step = minStep\n\t\t}\n\t}\n\n\t// prepare the variables for the corresponding query type","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L743-L779","documentation":"ParseQueryRangeParams failed to JSON-decode the POST body into v3.QueryRangeParamsV3, returning ErrorBadData. Any malformed JSON or schema mismatch (wrong types, unknown enum values for panelType, etc.) triggers it.","triggerScenarios":"POST /api/v3/query_range with invalid JSON, wrong field types (e.g. start as string when number expected), or a compositeQuery shape that doesn't match the struct.","commonSituations":"Manually crafting API payloads instead of using the UI; version drift where the payload schema changed; proxies stripping or truncating the body; sending an empty body.","solutions":["Validate the body against the QueryRangeParamsV3 schema (start/end in microseconds, compositeQuery with panelType and queries)","Send Content-Type: application/json and a well-formed body","Capture the exact body and decode it locally with json.Decoder to see the field-level error"],"exampleFix":"// before\ncurl -X POST /api/v3/query_range -d '{\"start\": \"now\"}'\n// after\ncurl -X POST /api/v3/query_range -H 'Content-Type: application/json' -d '{\"start\":1700000000000000,\"end\":1700003600000000,\"compositeQuery\":{\"panelType\":\"graph\",\"builderQueries\":{}}}'","handlingStrategy":"try-catch","validationCode":"var p v3.QueryRangeParamsV3\nif err := json.NewDecoder(bytes.NewReader(body)).Decode(&p); err != nil { return fmt.Errorf(\"body does not match QueryRangeParamsV3: %v\", err) }","typeGuard":null,"tryCatchPattern":"On 400 with 'cannot parse the request body', log the raw body and the wrapped json error to identify the exact offending field.","preventionTips":["Generate request payloads from typed structs (Go/TS types matching v3)","Always set Content-Type: application/json","Validate timestamps are numeric microseconds"],"tags":["signoz","query-range","json-decode","bad-request"],"backgroundTag":"json-deserialization-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}