{"record":{"id":"1dc65c93287e8d57","repo":"bytebase/bytebase","slug":"codeinternal-1dc65c","errorCode":"CodeInternal","errorMessage":"failed to get issue","messagePattern":"failed to get issue","errorType":"error_code","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"backend/api/v1/issue_service_review_run.go","lineNumber":43,"sourceCode":"// RUNNING execution is superseded, the attempt number is bumped, and the\n// returned run is AVAILABLE.\nfunc (s *IssueService) RunReview(ctx context.Context, req *connect.Request[v1pb.RunReviewRequest]) (*connect.Response[v1pb.ReviewRun], error) {\n\tprojectID, issueUID, reviewRunID, err := common.GetProjectIDIssueUIDReviewRunID(req.Msg.Name)\n\tif err != nil {\n\t\treturn nil, connect.NewError(connect.CodeInvalidArgument, err)\n\t}\n\treviewType, ok := reviewRunTypeFromID(reviewRunID)\n\tif !ok {\n\t\treturn nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf(\"unknown reviewer type %q\", reviewRunID))\n\t}\n\n\tissue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{\n\t\tWorkspace:  common.GetWorkspaceIDFromContext(ctx),\n\t\tProjectIDs: []string{projectID},\n\t\tUID:        &issueUID,\n\t})\n\tif err != nil {\n\t\treturn nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, \"failed to get issue\"))\n\t}\n\tif issue == nil {\n\t\treturn nil, connect.NewError(connect.CodeNotFound, errors.Errorf(\"issue %d not found in project %s\", issueUID, projectID))\n\t}\n\tif issue.Status != storepb.Issue_OPEN {\n\t\treturn nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf(\"review runs only on an open issue; issue is %s\", issue.Status))\n\t}\n\tif issue.PlanUID == nil {\n\t\treturn nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf(\"issue %d has no SQL to review\", issueUID))\n\t}\n\tplan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{ProjectID: projectID, UID: issue.PlanUID})\n\tif err != nil {\n\t\treturn nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, \"failed to get plan\"))\n\t}\n\tif plan == nil {\n\t\treturn nil, connect.NewError(connect.CodeNotFound, errors.Errorf(\"plan %d not found in project %s\", *issue.PlanUID, projectID))\n\t}\n\tif plan.Config.GetHasRollout() {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/api/v1/issue_service_review_run.go#L25-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (client blindly retries)\nclient.RunReview(ctx, req)\n// after (client retries only on CodeInternal/unavailable with backoff)\nif connect.CodeOf(err) == connect.CodeInternal {\n    time.Sleep(backoff)\n    resp, err = client.RunReview(ctx, req)\n}","handlingStrategy":"retry","validationCode":"// Pre-check DB reachability from the operator side\n// psql \"$PG_URL\" -c 'SELECT 1' || echo 'metadata DB unreachable'","typeGuard":null,"tryCatchPattern":"if connect.CodeOf(err) == connect.CodeInternal {\n    // inspect err for wrapped store cause; retry with backoff\n}","preventionTips":["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"],"tags":["database","connectrpc","internal-error","storage"],"backgroundTag":"database-query-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}