{"record":{"id":"47dc567e51dd83a2","repo":"SigNoz/signoz","slug":"timeshiftby-param-should-be-a-number","errorCode":null,"errorMessage":"timeShiftBy param should be a number","messagePattern":"timeShiftBy param should be a number","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1123,"sourceCode":"\tif b.Expression == \"\" {\n\t\treturn fmt.Errorf(\"expression is required\")\n\t}\n\n\tif len(b.Functions) > 0 {\n\t\tfor _, function := range b.Functions {\n\t\t\tif err := function.Name.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"function name is invalid: %w\", err)\n\t\t\t}\n\t\t\tif function.Name == FunctionNameTimeShift {\n\t\t\t\tif len(function.Args) == 0 {\n\t\t\t\t\treturn fmt.Errorf(\"timeShiftBy param missing in query\")\n\t\t\t\t}\n\t\t\t\t_, ok := function.Args[0].(float64)\n\t\t\t\tif !ok {\n\t\t\t\t\t// if string, attempt to convert to float\n\t\t\t\t\ttimeShiftBy, err := strconv.ParseFloat(function.Args[0].(string), 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"timeShiftBy param should be a number\")\n\t\t\t\t\t}\n\t\t\t\t\tfunction.Args[0] = timeShiftBy\n\t\t\t\t}\n\t\t\t} else if function.Name == FunctionNameEWMA3 ||\n\t\t\t\tfunction.Name == FunctionNameEWMA5 ||\n\t\t\t\tfunction.Name == FunctionNameEWMA7 {\n\t\t\t\tif len(function.Args) == 0 {\n\t\t\t\t\treturn fmt.Errorf(\"alpha param missing in query\")\n\t\t\t\t}\n\t\t\t\talpha, ok := function.Args[0].(float64)\n\t\t\t\tif !ok {\n\t\t\t\t\t// if string, attempt to convert to float\n\t\t\t\t\talpha, err := strconv.ParseFloat(function.Args[0].(string), 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"alpha param should be a float\")\n\t\t\t\t\t}\n\t\t\t\t\tfunction.Args[0] = alpha\n\t\t\t\t}","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1105-L1141","documentation":"timeShift's first argument must be a number (or a string parseable as a float). This error fires when Args[0] is neither float64 nor a string that strconv.ParseFloat can parse (the failed string type-assertion would panic otherwise; a parse error returns this message).","triggerScenarios":"\"args\":[\"1h\"] or [null] or [true] for timeShift — the code only accepts float64 or numeric strings like \"3600\".","commonSituations":"Passing duration strings (\"30m\", \"1h\") instead of seconds; JSON where the value arrives as a map or null; language clients that serialize numbers as non-numeric strings.","solutions":["Pass the shift as a plain number of seconds (3600) or a numeric string (\"3600\")","Convert duration strings to seconds client-side before building the query"],"exampleFix":"// before\n{\"name\":\"timeShift\",\"args\":[\"1h\"]}\n// after\n{\"name\":\"timeShift\",\"args\":[3600]}","handlingStrategy":"type-guard","validationCode":"if _, err := strconv.ParseFloat(fmt.Sprint(args[0]), 64); err != nil { return fmt.Errorf(\"timeShift arg must be numeric\") }","typeGuard":"func isNumericArg(a interface{}) bool {\n  switch a.(type) { case float64, int: return true; case string: _, err := strconv.ParseFloat(a.(string), 64); return err == nil }\n  return false\n}","tryCatchPattern":null,"preventionTips":["Always serialize timeShift args as JSON numbers (seconds)","Convert durations client-side; never send \"30m\" style strings"],"tags":["signoz","query-builder","timeshift","type-mismatch"],"backgroundTag":"query-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}