bytebase/bytebase · error
CodeNotFound
CodeNotFound
Error message
project not found for id: %v
What it means
SearchIssues returns CodeNotFound when the explicitly requested project ID in the parent does not exist in the store (GetProject returned nil, nil). This is a clean not-found, not an internal failure — the project was deleted or the ID is wrong.
Source
Thrown at backend/api/v1/issue_service.go:390
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get projectIDs"))
}
if projectIDsFilter != nil {
projectIDs = *projectIDsFilter
}
} else {
// Resolve the project first so an unknown parent is a NotFound rather
// than an INTERNAL out of CheckPermission's own project lookup. This
// matches what the ACL interceptor does for the IAM-authorized RPCs.
project, err := s.store.GetProject(ctx, &store.FindProjectMessage{
Workspace: common.GetWorkspaceIDFromContext(ctx),
ResourceID: &projectID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get project"))
}
if project == nil {
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project not found for id: %v", projectID))
}
ok, err := s.iamManager.CheckPermission(ctx, permission.IssuesGet, user, common.GetWorkspaceIDFromContext(ctx), projectID)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to check permission %q", permission.IssuesGet))
}
if !ok {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("user does not have permission %q in %q", permission.IssuesGet, req.Msg.Parent))
}
projectIDs = append(projectIDs, projectID)
}
issueFind.ProjectIDs = projectIDs
issueFind.ExcludeDraft = true
if err := s.setNextApproverRoles(ctx, issueFind, approver); err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
issues, err := s.store.ListIssues(ctx, issueFind)
if err != nil {View on GitHub (pinned to 1870550677)
Solutions
- Verify the project ID via the project list API or UI and correct the parent.
- Recreate the project if it was deleted.
- Re-fetch project IDs instead of caching them.
- Confirm you are hitting the right Bytebase instance/environment.
Example fix
// before
const parent = 'projects/prj-old-deleted';
// after: verify the project exists first
const projects = await projectServiceClient.listProjects({});
const parent = `projects/${projects.find(p => p.id === 'my-project')?.id}`;
if (!parent.includes('prj-')) throw new Error('project id missing'); Defensive patterns
Strategy: validation
Validate before calling
const projects = await projectServiceClient.listProjects({});
const exists = projects.projects.some(p => `projects/${p.id}` === parent);
if (!exists) throw new Error(`project ${parent} does not exist`); Prevention
- Never hardcode project IDs; resolve them from listProjects.
- Handle deletions: re-resolve project IDs before recurring jobs.
- Validate the parent matches /^projects\/[A-Za-z0-9-]+$/ client-side.
- Confirm the target environment before searching.
When it happens
Trigger: Calling SearchIssues with parent="projects/<id>" where <id> is misspelled, deleted, or belongs to another environment.
Common situations: Stale project IDs cached in client tooling; project deleted by an admin; typos in the parent resource name; using a project from a different Bytebase instance.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/2b2b5328e64d58ef.
Report an issue: GitHub.