bytebase/bytebase · critical
CodeInternal
CodeInternal
Error message
failed to get issue
What it means
RunReview wraps any error returned by store.GetIssue in a connect CodeInternal error with the message "failed to get issue". This means the metadata database lookup itself failed (as opposed to the issue simply not existing, which yields CodeNotFound). It indicates a storage-layer or query failure, not a problem with the caller's request payload.
Source
Thrown at backend/api/v1/issue_service_review_run.go:43
// RUNNING execution is superseded, the attempt number is bumped, and the
// returned run is AVAILABLE.
func (s *IssueService) RunReview(ctx context.Context, req *connect.Request[v1pb.RunReviewRequest]) (*connect.Response[v1pb.ReviewRun], error) {
projectID, issueUID, reviewRunID, err := common.GetProjectIDIssueUIDReviewRunID(req.Msg.Name)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, err)
}
reviewType, ok := reviewRunTypeFromID(reviewRunID)
if !ok {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unknown reviewer type %q", reviewRunID))
}
issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
Workspace: common.GetWorkspaceIDFromContext(ctx),
ProjectIDs: []string{projectID},
UID: &issueUID,
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get issue"))
}
if issue == nil {
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("issue %d not found in project %s", issueUID, projectID))
}
if issue.Status != storepb.Issue_OPEN {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("review runs only on an open issue; issue is %s", issue.Status))
}
if issue.PlanUID == nil {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("issue %d has no SQL to review", issueUID))
}
plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{ProjectID: projectID, UID: issue.PlanUID})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get plan"))
}
if plan == nil {
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("plan %d not found in project %s", *issue.PlanUID, projectID))
}
if plan.Config.GetHasRollout() {View on GitHub (pinned to 1870550677)
Solutions
- Check that the Bytebase metadata Postgres is reachable and healthy (PG_URL configuration, psql connectivity).
- Inspect backend logs for the wrapped root cause under this message — the pkg/errors chain contains the real driver error.
- Retry the RunReview call if the failure was transient (connection blip, timeout).
- Verify database migrations completed (backend/migrator) so the issue table schema matches expectations.
- If persistent, restart the backend and check connection-pool sizing.
Example fix
// before (client blindly retries)
client.RunReview(ctx, req)
// after (client retries only on CodeInternal/unavailable with backoff)
if connect.CodeOf(err) == connect.CodeInternal {
time.Sleep(backoff)
resp, err = client.RunReview(ctx, req)
} Defensive patterns
Strategy: retry
Validate before calling
// Pre-check DB reachability from the operator side // psql "$PG_URL" -c 'SELECT 1' || echo 'metadata DB unreachable'
Try / catch
if connect.CodeOf(err) == connect.CodeInternal {
// inspect err for wrapped store cause; retry with backoff
} Prevention
- Monitor metadata Postgres health and alert on outages
- Size the DB connection pool for peak automation concurrency
- Keep migrations applied before deploying new backend versions
- Use exponential backoff with jitter for RunReview retries
When it happens
Trigger: Calling RunReview on projects/{project}/issues/{issue} when the underlying GetIssue store query fails — e.g. the metadata Postgres is unreachable, the connection pool is exhausted, the query timed out, or the store returned a non-EOF unexpected error.
Common situations: Metadata database down or restarted during a deploy; network partition between the Bytebase backend and its metadata DB; misconfigured PG_URL; transient connection pool exhaustion under load; schema drift after a partial migration.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/1dc65c93287e8d57.
Report an issue: GitHub.