{"record":{"id":"e6f52637f69a69d3","repo":"bytebase/bytebase","slug":"codeinvalidargument-e6f526","errorCode":"CodeInvalidArgument","errorMessage":"invalid project filter %q","messagePattern":"invalid project filter %q","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"backend/api/v1/instance_service.go","lineNumber":310,"sourceCode":"\t\tswitch call.FunctionName() {\n\t\tcase celoperators.LogicalAnd, celoperators.LogicalOr:\n\t\t\tfor _, arg := range call.Args() {\n\t\t\t\tif err := validate(arg); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\tcase celoperators.Equals:\n\t\t\tvariable, value := getVariableAndValueFromExpr(expr)\n\t\t\tif variable != \"project\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tprojectName, ok := value.(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tprojectID, err := common.GetProjectID(projectName)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"invalid project filter %q\", projectName)\n\t\t\t}\n\t\t\tif projectID != *parentProjectID {\n\t\t\t\treturn errors.Errorf(\"project filter %q does not match parent %q\", projectName, common.FormatProject(*parentProjectID))\n\t\t\t}\n\t\tdefault:\n\t\t\tfor _, arg := range call.Args() {\n\t\t\t\tif err := validate(arg); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\treturn validate(ast.NativeRep().Expr())\n}\n\n// ListInstanceDatabase list all databases in the instance.\nfunc (s *InstanceService) ListInstanceDatabase(ctx context.Context, req *connect.Request[v1pb.ListInstanceDatabaseRequest]) (*connect.Response[v1pb.ListInstanceDatabaseResponse], error) {","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/api/v1/instance_service.go#L292-L328","documentation":"The ListInstances-style filter validator in InstanceService rejects a CEL filter whose `project` argument cannot be parsed into a valid project resource ID via common.GetProjectID. It is thrown because a filter value like `projects/abc/databases/x` or a malformed name does not match the expected `projects/{id}` format.","triggerScenarios":"Calling ListInstances (or other filtered instance list APIs) with a `filter` expression where the project value is not a parsable project resource name, e.g. filter=\"project=\\\"foo/bar\\\"\" or an empty/garbage string.","commonSituations":"Hand-written CEL filters, copy-pasted resource names from other APIs, passing a project title/display name instead of the resource name, or clients that URL-encoded or truncated the project part.","solutions":["Pass the full project resource name in the filter, formatted as `projects/{project-id}`.","Extract the project ID from the UI/API response (e.g. the project's `name` field) rather than constructing it manually.","If the parent already scopes the request, drop the redundant project filter entirely."],"exampleFix":"// before\nfilter: \"project=\\\"my-project\\\"\"\n// after\nfilter: \"project=\\\"projects/my-project\\\"\"","handlingStrategy":"validation","validationCode":"const m = /^projects\\/([a-z0-9-]+)$/.exec(filterProject);\nif (!m) throw new Error(\"project filter must be projects/{id}\");","typeGuard":"function isValidProjectName(v) { return typeof v === \"string\" && /^projects\\/[a-z0-9-]+$/.test(v); }","tryCatchPattern":null,"preventionTips":["Always build filter values with FormatProject(projectID).","Validate CEL filter strings against the expected project name format before sending.","Reuse one helper for parent and filter construction so they stay consistent."],"tags":["grpc","validation","filter","cel"],"backgroundTag":"invalid-argument-format","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"}