{"record":{"id":"ea20fcb2f66c6d1e","repo":"gastownhall/beads","slug":"failed-to-update-issue-w","errorCode":null,"errorMessage":"failed to update issue: %w","messagePattern":"failed to update issue: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compact/compactor.go","lineNumber":148,"sourceCode":"\t\treturn fmt.Errorf(\"compaction would increase size (%d → %d bytes), keeping original\", originalSize, compactedSize)\n\t}\n\n\t// Archive the original content BEFORE the destructive overwrite, so the\n\t// compaction is reversible (bd restore reads this snapshot). If archiving\n\t// fails we abort with the original content intact rather than lose it.\n\tif err := c.store.SnapshotIssue(ctx, issueID, 1); err != nil {\n\t\treturn fmt.Errorf(\"failed to archive pre-compaction snapshot: %w\", err)\n\t}\n\n\t// Update issue with summarized content\n\tupdates := map[string]interface{}{\n\t\t\"description\":         summary,\n\t\t\"design\":              \"\",\n\t\t\"notes\":               \"\",\n\t\t\"acceptance_criteria\": \"\",\n\t}\n\tif err := c.store.UpdateIssue(ctx, issueID, updates, \"compactor\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to update issue: %w\", err)\n\t}\n\n\t// Record compaction metadata with git commit hash\n\tcommitHash := GetCurrentCommitHash()\n\tif err := c.store.ApplyCompaction(ctx, issueID, 1, originalSize, compactedSize, commitHash); err != nil {\n\t\treturn fmt.Errorf(\"failed to apply compaction metadata: %w\", err)\n\t}\n\n\t// Add comment about compaction\n\tsavingBytes := originalSize - compactedSize\n\tcomment := fmt.Sprintf(\"Tier 1 compaction: %d → %d bytes (saved %d)\", originalSize, compactedSize, savingBytes)\n\tif err := c.store.AddComment(ctx, issueID, \"compactor\", comment); err != nil {\n\t\treturn fmt.Errorf(\"failed to add compaction comment: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/compact/compactor.go#L130-L166","documentation":"CompactTier1 in the compactor writes the AI-generated summary back to the issue store via store.UpdateIssue, wrapping any storage-layer failure with this message. It means the issue metadata could not be persisted, so tier-1 compaction aborted before recording compaction metadata. The underlying cause is always in the wrapped error from the store driver.","triggerScenarios":"store.UpdateIssue(ctx, issueID, updates, \"compactor\") returns a non-nil error during CompactTier1 — e.g. database unavailable, issue deleted concurrently, constraint violation on the updates map, or Dolt/driver write failure.","commonSituations":"The issue was closed or deleted by another agent while compaction ran; the local Dolt database is locked or corrupt; disk full; a driver-level schema or permission error.","solutions":["Inspect the wrapped cause (%w) — run `bd doctor` or check the store/driver logs for the underlying database error","Verify the issue still exists with `bd show <issueID>` before retrying compaction","Retry compaction; if the DB is locked or offline, restart/repair the Dolt store and rerun","Run the compaction again on a single issue with runCompactSingle to isolate the failing issue"],"exampleFix":"// before\nif err := c.store.UpdateIssue(ctx, issueID, updates, \"compactor\"); err != nil {\n\treturn fmt.Errorf(\"failed to update issue: %w\", err)\n}\n// after\nif err := c.store.UpdateIssue(ctx, issueID, updates, \"compactor\"); err != nil {\n\tif errors.Is(err, types.ErrNotFound) {\n\t\treturn fmt.Errorf(\"issue %s deleted during compaction: %w\", issueID, err)\n\t}\n\treturn fmt.Errorf(\"failed to update issue %s: %w\", issueID, err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: verify the issue exists and store is healthy before compacting\nif _, err := store.GetIssue(ctx, issueID); err != nil {\n\treturn fmt.Errorf(\"issue %s not available for compaction: %w\", issueID, err)\n}","typeGuard":null,"tryCatchPattern":"if err := client.CompactTier1(ctx, issueID); err != nil {\n\tvar storeErr *store.Error\n\tif errors.As(err, &storeErr) {\n\t\tlog.Printf(\"storage failure during compaction: %v\", storeErr)\n\t}\n\treturn err\n}","preventionTips":["Run `bd doctor` before large batch compactions to validate the store","Ensure adequate disk space for the Dolt database","Avoid concurrent mutations (delete/close) of issues being compacted"],"tags":["storage","compaction","database"],"backgroundTag":"database-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}