{"record":{"id":"ac5e6e7faf192b5d","repo":"SigNoz/signoz","slug":"invalid-expression-s-v","errorCode":null,"errorMessage":"invalid expression %s: %v","messagePattern":"invalid expression (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":713,"sourceCode":"\tvar expressions []string\n\tfor _, q := range qp.CompositeQuery.BuilderQueries {\n\t\texpressions = append(expressions, q.Expression)\n\t}\n\terrs := validateExpressions(expressions, queryBuilder.EvalFuncs, qp.CompositeQuery)\n\tif len(errs) > 0 {\n\t\treturn multierr.Combine(errs...)\n\t}\n\treturn nil\n}\n\n// validateExpressions validates the math expressions using the list of\n// allowed functions.\nfunc validateExpressions(expressions []string, funcs map[string]govaluate.ExpressionFunction, cq *v3.CompositeQuery) []error {\n\tvar errs []error\n\tfor _, exp := range expressions {\n\t\tevalExp, err := govaluate.NewEvaluableExpressionWithFunctions(exp, funcs)\n\t\tif err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"invalid expression %s: %v\", exp, err))\n\t\t\tcontinue\n\t\t}\n\t\tfor _, v := range evalExp.Vars() {\n\t\t\tvar hasVariable bool\n\t\t\tfor _, q := range cq.BuilderQueries {\n\t\t\t\tif q.Expression == v {\n\t\t\t\t\thasVariable = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !hasVariable {\n\t\t\t\terrs = append(errs, fmt.Errorf(\"unknown variable %s\", v))\n\t\t\t}\n\t\t}\n\t}\n\treturn errs\n}\n","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L695-L731","documentation":"In query-builder validation, each expression string is compiled with govaluate.NewEvaluableExpressionWithFunctions. If the expression has syntax errors (unbalanced parens, bad tokens, unknown function names not in the allowed funcs map), this error is collected.","triggerScenarios":"POST /api/v3/query_range with a builder query expression like 'A + ' , 'sum(', or using a function not in the allowed function map for your SigNoz version.","commonSituations":"Hand-crafting formulas in the query builder UI/API; using newly added functions against an older SigNoz; copy-paste introducing smart quotes or invisible characters.","solutions":["Fix the arithmetic/functional expression syntax (balanced parens, valid operators)","Verify every function used exists in the allowed functions for your version (see constants/functions docs)","Test the expression locally with govaluate or in the UI formula box first"],"exampleFix":"// before\n{\"expression\": \"A +\"}\n// after\n{\"expression\": \"A + B\"}","handlingStrategy":"validation","validationCode":"if _, err := govaluate.NewEvaluableExpressionWithFunctions(expr, allowedFuncs); err != nil { return fmt.Errorf(\"bad expression: %v\", err) }","typeGuard":null,"tryCatchPattern":"Aggregate the errs slice returned by validateExpressions and show all expression errors at once in the UI/API response.","preventionTips":["Compile expressions client-side with a govaluate-equivalent validator","Lint formulas in the dashboard UI before saving"],"tags":["signoz","query-builder","expression","govaluate","validation"],"backgroundTag":"expression-parse-error","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}