{"record":{"id":"8bd3fdb9758e7093","repo":"gastownhall/beads","slug":"failed-to-fetch-issue-w","errorCode":null,"errorMessage":"failed to fetch issue: %w","messagePattern":"failed to fetch issue: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compact/compactor.go","lineNumber":107,"sourceCode":"\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\t// Check eligibility before fetching issue (fail fast)\n\teligible, reason, err := c.store.CheckEligibility(ctx, issueID, 1)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to verify eligibility: %w\", err)\n\t}\n\tif !eligible {\n\t\tif reason != \"\" {\n\t\t\treturn fmt.Errorf(\"issue %s is not eligible for Tier 1 compaction: %s\", issueID, reason)\n\t\t}\n\t\treturn fmt.Errorf(\"issue %s is not eligible for Tier 1 compaction\", issueID)\n\t}\n\n\tissue, err := c.store.GetIssue(ctx, issueID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to fetch issue: %w\", err)\n\t}\n\n\t// Calculate original size\n\toriginalSize := len(issue.Description) + len(issue.Design) + len(issue.Notes) + len(issue.AcceptanceCriteria)\n\n\tif c.config.DryRun {\n\t\treturn fmt.Errorf(\"dry-run: would compact %s (original size: %d bytes)\", issueID, originalSize)\n\t}\n\n\t// Get summary from AI\n\tsummary, err := c.summarizer.SummarizeTier1(ctx, issue)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to summarize: %w\", err)\n\t}\n\n\t// Check if compaction would actually reduce size\n\tcompactedSize := len(summary)\n\tif compactedSize >= originalSize {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/compact/compactor.go#L89-L125","documentation":"After passing the eligibility check, CompactTier1 fetches the full issue via store.GetIssue. If that fetch fails, the compaction aborts with this wrapped error. This is a storage-layer read failure on a record the eligibility check just saw, so it often indicates a race or backend problem.","triggerScenarios":"store.GetIssue(ctx, issueID) returns a non-nil error — e.g. the issue was deleted between CheckEligibility and GetIssue, the database connection dropped, or the storage backend returned an internal error.","commonSituations":"Concurrent deletion of the issue while a compaction runs; database outage mid-operation; corrupted database; transient network failure against a remote Dolt server.","solutions":["Check whether the issue still exists (bd show <issueID>)","Inspect the wrapped error for the storage root cause","Retry once the database/connection is healthy","Re-run eligibility + compaction after any concurrent writers have finished"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := store.GetIssue(ctx, issueID); err != nil {\n    return fmt.Errorf(\"issue %s unreadable before compaction: %w\", issueID, err)\n}","typeGuard":null,"tryCatchPattern":"err := c.CompactTier1(ctx, id)\nif err != nil && strings.Contains(err.Error(), \"failed to fetch issue\") {\n    time.Sleep(backoff)\n    err = c.CompactTier1(ctx, id)\n}\nreturn err","preventionTips":["Avoid deleting issues while a compaction batch is running","Use a context with adequate timeout for the store read","Retry fetch failures — they are often transient connection drops"],"tags":["go","storage","database","read-failure"],"backgroundTag":"record-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}