{"record":{"id":"58464ebbca8912da","repo":"SigNoz/signoz","slug":"operator-must-be-and-or-or","errorCode":null,"errorMessage":"operator must be AND or OR","messagePattern":"operator must be AND or OR","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1191,"sourceCode":"\tItems    []FilterItem `json:\"items\"`\n}\n\nfunc (f *FilterSet) Clone() *FilterSet {\n\tif f == nil {\n\t\treturn nil\n\t}\n\treturn &FilterSet{\n\t\tOperator: f.Operator,\n\t\tItems:    f.Items,\n\t}\n}\n\nfunc (f *FilterSet) Validate() error {\n\tif f == nil {\n\t\treturn nil\n\t}\n\tif f.Operator != \"\" && f.Operator != \"AND\" && f.Operator != \"OR\" {\n\t\treturn fmt.Errorf(\"operator must be AND or OR\")\n\t}\n\tfor _, item := range f.Items {\n\t\tif err := item.Key.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"filter item key is invalid: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// For serializing to and from db\nfunc (f *FilterSet) Scan(src interface{}) error {\n\tif data, ok := src.([]byte); ok {\n\t\treturn json.Unmarshal(data, &f)\n\t}\n\treturn nil\n}\n\nfunc (f *FilterSet) Value() (driver.Value, error) {","sourceCodeStart":1173,"sourceCodeEnd":1209,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1173-L1209","documentation":"FilterSet.Validate() requires the Operator field to be empty (default) or exactly \"AND\"/\"OR\" (case-sensitive). Any other string is rejected.","triggerScenarios":"Sending a filter set with \"operator\":\"and\" (lowercase), \"AND \", \"not\", or \"&&\" in a query builder payload.","commonSituations":"Lowercasing middleware, hand-crafted curl payloads, or client enums that use different tokens (&& / ||).","solutions":["Use exactly \"AND\" or \"OR\" uppercase, or omit the field entirely","Normalize the operator client-side: trim + uppercase + whitelist before sending"],"exampleFix":"// before\n{\"operator\":\"and\",\"items\":[...]}\n// after\n{\"operator\":\"AND\",\"items\":[...]}","handlingStrategy":"validation","validationCode":"op := strings.ToUpper(strings.TrimSpace(fs.Operator))\nif op != \"\" && op != \"AND\" && op != \"OR\" { return errors.New(\"operator must be AND or OR\") }","typeGuard":"func isValidFilterOperator(op string) bool { return op == \"\" || op == \"AND\" || op == \"OR\" }","tryCatchPattern":null,"preventionTips":["Whitelist and normalize operators to uppercase before sending","Omit operator to use the default"],"tags":["signoz","query-builder","filters","validation"],"backgroundTag":"query-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}