gastownhall/beads · warning
failed to add compaction comment: %w
Error message
failed to add compaction comment: %w
What it means
The final step of CompactTier1 adds an audit comment describing bytes saved. If store.AddComment fails, the issue and metadata are already written but the human-visible compaction comment is missing. Compaction itself succeeded; only the audit trail comment is lost.
Source
Thrown at internal/compact/compactor.go:161
"design": "",
"notes": "",
"acceptance_criteria": "",
}
if err := c.store.UpdateIssue(ctx, issueID, updates, "compactor"); err != nil {
return fmt.Errorf("failed to update issue: %w", err)
}
// Record compaction metadata with git commit hash
commitHash := GetCurrentCommitHash()
if err := c.store.ApplyCompaction(ctx, issueID, 1, originalSize, compactedSize, commitHash); err != nil {
return fmt.Errorf("failed to apply compaction metadata: %w", err)
}
// Add comment about compaction
savingBytes := originalSize - compactedSize
comment := fmt.Sprintf("Tier 1 compaction: %d → %d bytes (saved %d)", originalSize, compactedSize, savingBytes)
if err := c.store.AddComment(ctx, issueID, "compactor", comment); err != nil {
return fmt.Errorf("failed to add compaction comment: %w", err)
}
return nil
}
// BatchResult holds the result of a single issue compaction in a batch.
type BatchResult struct {
IssueID string
OriginalSize int
CompactedSize int
Err error
}
// CompactTier1Batch compacts multiple issues at Tier 1 concurrently.
func (c *Compactor) CompactTier1Batch(ctx context.Context, issueIDs []string) ([]BatchResult, error) {
results := make([]BatchResult, len(issueIDs))
sem := make(chan struct{}, c.config.Concurrency)
var wg sync.WaitGroupView on GitHub (pinned to 71377f2769)
Solutions
- Add the comment manually with `bd update <issueID> --notes` or a `bd` comment command if the trail matters
- Re-run compaction only if you need the comment; otherwise treat compaction as complete
- Check store/driver logs for the wrapped cause (lock, connection, disk)
- Retry `bd compact` — subsequent runs will append a fresh comment
Defensive patterns
Strategy: try-catch
Try / catch
if err := client.CompactTier1(ctx, issueID); err != nil {
if strings.Contains(err.Error(), "compaction comment") {
// compaction succeeded; comment is best-effort — safe to ignore or re-add
log.Printf("compacted %s but comment failed: %v", issueID, err)
return nil
}
return err
} Prevention
- Treat the comment step as advisory; verify saved-bytes notes manually when it fails
- Avoid concurrent writers on the same issue
- Keep the store healthy so all three sequential writes succeed
When it happens
Trigger: store.AddComment(ctx, issueID, "compactor", comment) returns an error during CompactTier1 — driver write failure or DB unavailable at the last write step.
Common situations: Transient database lock or connection drop between the three sequential writes; comment storage quota or schema issue; concurrent write conflict on the same issue.
Related errors
- failed to update issue: %w
- failed to apply compaction metadata: %w
- scan same-content compaction snapshots: %w
- ErrTransaction
- ErrQuery
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/46ebf92065995579.
Report an issue: GitHub.