{"record":{"id":"8f1a394596db9009","repo":"bytebase/bytebase","slug":"unsupported-variable-q-8f1a39","errorCode":null,"errorMessage":"unsupported variable %q","messagePattern":"unsupported variable %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/store/saved_query.go","lineNumber":946,"sourceCode":"\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tq.Or(\"?\", qq)\n\t\t\t}\n\t\t\treturn qb.Q().Space(\"(?)\", q), nil\n\t\tcase celoperators.LogicalAnd:\n\t\t\tfor _, arg := range expr.AsCall().Args() {\n\t\t\t\tqq, err := getFilter(arg)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tq.And(\"?\", qq)\n\t\t\t}\n\t\t\treturn qb.Q().Space(\"(?)\", q), nil\n\t\tcase celoperators.Equals, celoperators.NotEquals:\n\t\t\tvariable, value := getVariableAndValueFromExpr(expr)\n\t\t\tif variable != \"creator\" {\n\t\t\t\treturn nil, errors.Errorf(\"unsupported variable %q\", variable)\n\t\t\t}\n\t\t\tcreator, ok := value.(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, errors.Errorf(\"invalid creator value %q\", value)\n\t\t\t}\n\t\t\tcreatorEmail := strings.TrimPrefix(creator, \"users/\")\n\t\t\tif creatorEmail == \"\" {\n\t\t\t\treturn nil, errors.New(\"invalid empty creator identifier\")\n\t\t\t}\n\t\t\tif functionName == celoperators.Equals {\n\t\t\t\treturn qb.Q().Space(\"saved_query.creator = ?\", creatorEmail), nil\n\t\t\t}\n\t\t\treturn qb.Q().Space(\"saved_query.creator != ?\", creatorEmail), nil\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"unexpected function %v\", functionName)\n\t\t}\n\t}\n","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/store/saved_query.go#L928-L964","documentation":"The saved-query filter translator only supports the variable `creator` in equality comparisons. When it extracts the variable name from a CEL ==/!= expression and it is anything else, it rejects the filter with \"unsupported variable\". The filter schema for listing saved queries is deliberately narrow, so unknown fields are hard errors rather than being silently ignored.","triggerScenarios":"Listing saved queries with a filter comparing any variable other than `creator`, e.g. `name == \"savedQueries/abc\"`, `title == \"x\"`, or `project == \"projects/1\"` in the `filter` parameter.","commonSituations":"Developers assuming full CEL filtering support and filtering on fields like title or updatedAt; copying filter expressions from other Bytebase resources (databases, issues) that support more variables; typos like `creater == ...`.","solutions":["Use only `creator` in the saved-query filter, e.g. `creator == \"users/foo@example.com\"`.","Drop the unsupported predicate and filter other fields client-side after listing.","Check the API documentation for the exact set of supported filter variables for this endpoint.","If server-side filtering on another field is needed, extend the switch in backend/store/saved_query.go to map that variable to a column."],"exampleFix":"// before\nfilter = \"title == \\\"daily\\\"\"\n// after\nfilter = \"creator == \\\"users/foo@example.com\\\"\"","handlingStrategy":"validation","validationCode":"const supportedVars = new Set([\"creator\"])\nfunction validateFilter(filter) {\n  for (const v of extractVariables(filter)) {\n    if (!supportedVars.has(v)) throw new Error(`unsupported variable '${v}'; only 'creator' is supported`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await listSavedQueries({ filter })\n} catch (e) {\n  if (String(e).includes(\"unsupported variable\")) {\n    // fall back to listing without filter and filter client-side\n    return listSavedQueries({}) \n  }\n  throw e\n}","preventionTips":["Keep a client-side schema of allowed filter variables per endpoint","Reuse the same filter-builder helper across the codebase so restrictions are centralized","Check endpoint-specific filter docs rather than assuming uniform CEL support"],"tags":["cel","filter","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}