{"record":{"id":"180c51b8caffd197","repo":"bytebase/bytebase","slug":"only-creator-support-operator","errorCode":null,"errorMessage":"only \"creator\" support \"!=\" operator","messagePattern":"only \"creator\" support \"!=\" operator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/store/saved_query.go","lineNumber":843,"sourceCode":"\t\t\t\t\treturn nil, errors.Errorf(\"expect string, got %T, hint: filter literals should be string\", value)\n\t\t\t\t}\n\t\t\t\tif strValue == \"\" {\n\t\t\t\t\treturn nil, errors.Errorf(`empty value for %q`, variable)\n\t\t\t\t}\n\n\t\t\t\tswitch variable {\n\t\t\t\tcase \"title\":\n\t\t\t\t\tif !allowTitleContains {\n\t\t\t\t\t\treturn nil, errors.Errorf(\"unsupport variable %q\", variable)\n\t\t\t\t\t}\n\t\t\t\t\treturn qb.Q().Space(\"LOWER(saved_query.name) LIKE ? ESCAPE '\\\\'\", containsPattern(strings.ToLower(strValue))), nil\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, errors.Errorf(\"unsupport variable %q\", variable)\n\t\t\t\t}\n\t\t\tcase celoperators.NotEquals:\n\t\t\t\tvariable, value := getVariableAndValueFromExpr(expr)\n\t\t\t\tif variable != \"creator\" {\n\t\t\t\t\treturn nil, errors.Errorf(`only \"creator\" support \"!=\" operator`)\n\t\t\t\t}\n\t\t\t\tcreator, ok := value.(string)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, errors.Errorf(\"invalid creator value %v, expect a string\", value)\n\t\t\t\t}\n\t\t\t\tuserID, err := getUserID(creator)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\treturn qb.Q().Space(\"saved_query.creator != ?\", userID), nil\n\t\t\tcase celoperators.In:\n\t\t\t\tvariable, value := getVariableAndValueFromExpr(expr)\n\t\t\t\trawList, ok := value.([]any)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, errors.Errorf(\"invalid %s value %q\", variable, value)\n\t\t\t\t}\n\t\t\t\tif len(rawList) == 0 {\n\t\t\t\t\treturn nil, errors.Errorf(\"empty %s filter\", variable)","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/store/saved_query.go#L825-L861","documentation":"Raised while translating a CEL `!=` call in the ListSavedQueries filter when the left-hand variable is anything other than `creator`. Only creator-inequality is implemented (`saved_query.creator != ?`); other fields must use `==` or `in`. The parser rejects the combination early instead of generating wrong SQL.","triggerScenarios":"Filters like `title != \"x\"`, `folder != \"a\"`, or `name != \"b\"` passed to ListSavedQueries.","commonSituations":"Building negated filters generically from UI toggles ('exclude value X') on fields the backend does not support negation for.","solutions":["Restrict `!=` usage to `creator`, e.g. `creator != \"users/alice\"`.","Express other exclusions via `in` on `name`, or drop the clause and filter results client-side.","To support `!=` on another field, extend the celoperators.NotEquals branch in backend/store/saved_query.go."],"exampleFix":"// before\nconst filter = 'folder != \"archive\"';\n// after\nconst filter = 'folder == \"archive\"'; // negate in app code if exclusion is needed","handlingStrategy":"validation","validationCode":"function assertNotEqualsTarget(field) {\n  if (field !== 'creator') {\n    throw new Error(`!= only supported on creator, got '${field}'`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await listSavedQueries({ filter });\n} catch (e) {\n  if (String(e).includes('only \"creator\" support')) {\n    // drop the negated clause and filter client-side\n  }\n}","preventionTips":["Restrict 'exclude value' UI toggles to the creator field","Prefer in/== clauses; implement exclusion in application code","Document the supported operator set per filter field"],"tags":["cel","filter","unsupported-operator"],"backgroundTag":"unsupported-operation","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}