{"record":{"id":"94988ae317f85c7d","repo":"bytebase/bytebase","slug":"issue-creation-request-failed","errorCode":null,"errorMessage":"issue creation request failed","messagePattern":"issue creation request failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/api/mcp/tool_change.go","lineNumber":443,"sourceCode":"\n// createIssue creates an issue linked to a plan.\nfunc (s *Server) createIssue(ctx context.Context, project, title, planName, description string) (string, string, error) {\n\tissue := map[string]any{\n\t\t\"title\": title,\n\t\t\"type\":  \"DATABASE_CHANGE\",\n\t\t\"plan\":  planName,\n\t}\n\tif description != \"\" {\n\t\tissue[\"description\"] = description\n\t}\n\tbody := map[string]any{\n\t\t\"parent\": project,\n\t\t\"issue\":  issue,\n\t}\n\n\tresp, err := s.apiRequest(ctx, \"/bytebase.v1.IssueService/CreateIssue\", body)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrap(err, \"issue creation request failed\")\n\t}\n\tif err := checkAPIResponse(resp, \"create issues\", \"bb.issues.create\"); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\tvar result struct {\n\t\tName           string `json:\"name\"`\n\t\tApprovalStatus string `json:\"approvalStatus\"`\n\t}\n\tif err := json.Unmarshal(resp.Body, &result); err != nil {\n\t\treturn \"\", \"\", errors.Wrap(err, \"failed to parse CreateIssue response\")\n\t}\n\treturn result.Name, result.ApprovalStatus, nil\n}\n\n// createRollout creates a rollout for a plan.\nfunc (s *Server) createRollout(ctx context.Context, planName string) (string, error) {\n\treturn s.callAPI(ctx, \"/bytebase.v1.RolloutService/CreateRollout\", \"create rollouts\", \"bb.rollouts.create\", map[string]any{","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/api/mcp/tool_change.go#L425-L461","documentation":"The MCP handleChange tool creates a Bytebase issue via the gRPC-gateway endpoint /bytebase.v1.IssueService/CreateIssue. When the underlying apiRequest returns an error (non-2xx response, network failure, or auth failure), it is wrapped as 'issue creation request failed' with the original cause attached.","triggerScenarios":"CreateIssue call fails due to invalid issue payload (bad project resource name, invalid pipeline steps), insufficient IAM permission (missing bb.issues.create), expired credentials, or the server rejecting the request.","commonSituations":"Referencing a project the token can't access, malformed change/rollout specification in the issue body, API version drift changing required fields, or auth token expiry mid-session.","solutions":["Read the wrapped cause for the API's error message (often a permission or validation error)","Verify the caller has bb.issues.create permission on the target project","Validate the project resource name and issue payload (title, steps) match the current proto schema","Re-authenticate if the credential may have expired"],"exampleFix":"// before\nbody := {\"parent\": \"projects/typo-name\", \"issue\": issue} // 404\n// after\nbody := {\"parent\": \"projects/actual-project-id\", \"issue\": issue} // valid resource name\nresp, err := s.apiRequest(ctx, \"/bytebase.v1.IssueService/CreateIssue\", body)","handlingStrategy":"try-catch","validationCode":"// verify permission and project before creating the issue\nconst allowed = await callTool('call_api', { operationId: 'bytebase.v1.ProjectService/GetProject', body: { name: project } });\nif (allowed.status !== 200) throw new Error(`project ${project} not accessible`);","typeGuard":"null","tryCatchPattern":"try {\n  result = await callTool('handleChange', { change: spec });\n} catch (err) {\n  if (String(err).includes('issue creation request failed')) {\n    // inspect cause: check bb.issues.create permission, project name, payload schema\n  }\n}","preventionTips":["Grant the caller bb.issues.create on the target project","Validate project resource names against the live project list","Keep payloads aligned with the current proto schema after upgrades","Refresh credentials before long MCP sessions"],"tags":["mcp","api","issue-creation"],"backgroundTag":"api-request-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"}