{"record":{"id":"736a940108aceb0e","repo":"gastownhall/beads","slug":"get-issue-s-w","errorCode":null,"errorMessage":"get issue %s: %w","messagePattern":"get issue (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/jira/client.go","lineNumber":241,"sourceCode":"\t\t\tstartAt += len(result.Issues)\n\t\t\tcontinue\n\t\t}\n\t\tif result.IsLast || result.NextPageToken == \"\" {\n\t\t\tbreak\n\t\t}\n\t\tnextPageToken = result.NextPageToken\n\t}\n\n\treturn allIssues, nil\n}\n\n// GetIssue fetches a single Jira issue by key (e.g., \"PROJ-123\").\nfunc (c *Client) GetIssue(ctx context.Context, key string) (*Issue, error) {\n\tapiURL := fmt.Sprintf(\"%s/issue/%s?fields=%s\", c.apiBase(), url.PathEscape(key), searchFields)\n\n\tbody, err := c.doRequest(ctx, \"GET\", apiURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get issue %s: %w\", key, err)\n\t}\n\n\tvar issue Issue\n\tif err := json.Unmarshal(body, &issue); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse issue response: %w\", err)\n\t}\n\n\treturn &issue, nil\n}\n\n// CreateIssue creates a new issue in Jira.\n// fields should include \"project\", \"summary\", \"issuetype\", and optionally other fields.\nfunc (c *Client) CreateIssue(ctx context.Context, fields map[string]interface{}) (*Issue, error) {\n\tpayload := map[string]interface{}{\"fields\": fields}\n\tdata, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshal create request: %w\", err)\n\t}","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/jira/client.go#L223-L259","documentation":"GetIssue wraps errors from doRequest for GET /issue/{key}. The HTTP layer failed: non-2xx status, auth failure, timeout, or network error. The issue key is embedded in the message so callers know which issue fetch failed. Also surfaces indirectly through CreateIssue, which calls GetIssue to hydrate the newly created issue.","triggerScenarios":"Calling GetIssue (or CreateIssue completing then hydrating) with a key the server rejects: 404 for nonexistent key, 401/403 for auth or permission problems, 400 for malformed key, or transport failure.","commonSituations":"Typo'd issue key or wrong project prefix; API token revoked/expired; account lacks browse permission on the project; Jira Server instance lacking API v3; CreateIssue succeeding but the subsequent fetch hitting a transient error.","solutions":["Check the wrapped HTTP error's status: 404 means verify the issue key exists and is visible to your account.","For 401/403, regenerate the API token and confirm permissions on the project.","For 404 on CreateIssue follow-up, verify APIVersion is correct so apiBase matches your deployment.","For timeouts/transient errors, retry the fetch."],"exampleFix":"// before\nissue, err := client.GetIssue(ctx, key)\n// after: tolerate transient failures on hydration\nissue, err := client.GetIssue(ctx, key)\nif err != nil && isTransient(err) {\n    issue, err = client.GetIssue(ctx, key)\n}","handlingStrategy":"try-catch","validationCode":"var jiraKeyRe = regexp.MustCompile(`^[A-Z][A-Z0-9]*-\\d+$`)\nfunc validIssueKey(k string) bool { return jiraKeyRe.MatchString(k) }\n// Also preflight permissions:\n// GET /rest/api/3/mypermissions?permissions=BROWSE_PROJECTS","typeGuard":"func isNotFound(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"404\")\n}","tryCatchPattern":"issue, err := client.GetIssue(ctx, key)\nif err != nil {\n    switch {\n    case isNotFound(err):\n        return nil, fmt.Errorf(\"issue %s does not exist or is not visible: %w\", key, err)\n    case errors.Is(err, context.DeadlineExceeded):\n        // transient: safe to retry\n        return client.GetIssue(ctx, key)\n    default:\n        return nil, err\n    }\n}","preventionTips":["Validate issue key format before calling","Confirm the account has Browse Projects permission for the key's project","Keep API tokens current and scoped correctly","Distinguish 404 (bad key/permission) from transient errors before retrying"],"tags":["jira","http","network","go"],"backgroundTag":"http-request-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}