bytebase/bytebase · error
CodeInvalidArgument
CodeInvalidArgument
Error message
invalid project filter %q
What it means
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.
Source
Thrown at backend/api/v1/instance_service.go:310
switch call.FunctionName() {
case celoperators.LogicalAnd, celoperators.LogicalOr:
for _, arg := range call.Args() {
if err := validate(arg); err != nil {
return err
}
}
case celoperators.Equals:
variable, value := getVariableAndValueFromExpr(expr)
if variable != "project" {
break
}
projectName, ok := value.(string)
if !ok {
return nil
}
projectID, err := common.GetProjectID(projectName)
if err != nil {
return errors.Errorf("invalid project filter %q", projectName)
}
if projectID != *parentProjectID {
return errors.Errorf("project filter %q does not match parent %q", projectName, common.FormatProject(*parentProjectID))
}
default:
for _, arg := range call.Args() {
if err := validate(arg); err != nil {
return err
}
}
}
return nil
}
return validate(ast.NativeRep().Expr())
}
// ListInstanceDatabase list all databases in the instance.
func (s *InstanceService) ListInstanceDatabase(ctx context.Context, req *connect.Request[v1pb.ListInstanceDatabaseRequest]) (*connect.Response[v1pb.ListInstanceDatabaseResponse], error) {View on GitHub (pinned to 1870550677)
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.
Example fix
// before filter: "project=\"my-project\"" // after filter: "project=\"projects/my-project\""
Defensive patterns
Strategy: validation
Validate before calling
const m = /^projects\/([a-z0-9-]+)$/.exec(filterProject);
if (!m) throw new Error("project filter must be projects/{id}"); Type guard
function isValidProjectName(v) { return typeof v === "string" && /^projects\/[a-z0-9-]+$/.test(v); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- invalid empty creator identifier
- CodeInvalidArgument
- failed to extract category
- unsupported expression type
- unsupported variable %q
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/e6f52637f69a69d3.
Report an issue: GitHub.