bytebase/bytebase · error
instance target %q does not belong to project %q
Error message
instance target %q does not belong to project %q
What it means
After parsing the instance resource name from a CreateDatabaseConfig target, unfoldSpecTargets checks that the instance's project component matches the project the plan belongs to. This error means the create-database target points at an instance owned by a different project — cross-project targeting is not allowed when creating databases through a plan.
Source
Thrown at backend/component/review/evaluator.go:520
return err
}
targets = append(targets, specTarget{
database: db,
sheetSha256: sheetSha256,
})
}
return nil
}
for _, spec := range specs {
switch config := spec.Config.(type) {
case *storepb.PlanConfig_Spec_CreateDatabaseConfig:
targetProjectID, instanceID, err := common.GetInstanceResourceName(config.CreateDatabaseConfig.Target)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse instance from target %q", config.CreateDatabaseConfig.Target)
}
if targetProjectID != nil && *targetProjectID != projectID {
return nil, errors.Errorf("instance target %q does not belong to project %q", config.CreateDatabaseConfig.Target, projectID)
}
if err := validateInstanceTarget(ctx, stores, targetProjectID, instanceID); err != nil {
return nil, err
}
// For CREATE_DATABASE, create a synthetic database message
// since the database doesn't exist yet
targets = append(targets, specTarget{
database: &store.DatabaseMessage{
InstanceID: instanceID,
DatabaseName: config.CreateDatabaseConfig.Database,
EffectiveEnvironmentID: new(config.CreateDatabaseConfig.Environment),
},
sheetSha256: "",
})
case *storepb.PlanConfig_Spec_ChangeDatabaseConfig:
if err := appendTargets(config.ChangeDatabaseConfig.Targets, config.ChangeDatabaseConfig.SheetSha256); err != nil {
return nil, errView on GitHub (pinned to 1870550677)
Solutions
- Change the spec target to an instance resource name under the same project as the plan ("projects/<plan-project>/instances/<i>")
- If the instance genuinely lives in another project, move the instance into this project or create the plan in that project instead
- Regenerate the plan from the UI/API instead of editing targets by hand
Example fix
// before (plan in project "app") "target": "projects/infra/instances/prod" // after "target": "projects/app/instances/prod"
Defensive patterns
Strategy: validation
Validate before calling
targetProject, targetInstance, err := common.GetInstanceResourceName(target)
if err == nil && targetProject != nil && *targetProject != plan.ProjectID {
return fmt.Errorf("instance %q belongs to project %s, not %s", target, *targetProject, plan.ProjectID)
} Prevention
- Only offer same-project instances in the create-database target picker
- Re-validate targets when copying plans across projects
- Avoid manual edits of cross-project targets in plan configs
When it happens
Trigger: A plan in project A has a spec whose CreateDatabaseConfig.Target is "projects/B/instances/x"; the targetProjectID parsed from the target differs from the plan's projectID.
Common situations: Plans copied between projects; UI retaining a stale target after the plan was moved; manual plan imports across projects; tenant projects referencing shared instances.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- database target %q does not belong to project %q
- failed to parse instance from target %q
- ClickHouse does not support collation, but got %s
- Snowflake does not support character set, but got %s
- Snowflake does not support collation, but got %s
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/431fa05749e5d9da.
Report an issue: GitHub.