gastownhall/beads · error

failed to update issue: %w

Error message

failed to update issue: %w

What it means

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.

Source

Thrown at internal/compact/compactor.go:148

		return fmt.Errorf("compaction would increase size (%d → %d bytes), keeping original", originalSize, compactedSize)
	}

	// Archive the original content BEFORE the destructive overwrite, so the
	// compaction is reversible (bd restore reads this snapshot). If archiving
	// fails we abort with the original content intact rather than lose it.
	if err := c.store.SnapshotIssue(ctx, issueID, 1); err != nil {
		return fmt.Errorf("failed to archive pre-compaction snapshot: %w", err)
	}

	// Update issue with summarized content
	updates := map[string]interface{}{
		"description":         summary,
		"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
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause (%w) — run `bd doctor` or check the store/driver logs for the underlying database error
  2. Verify the issue still exists with `bd show <issueID>` before retrying compaction
  3. Retry compaction; if the DB is locked or offline, restart/repair the Dolt store and rerun
  4. Run the compaction again on a single issue with runCompactSingle to isolate the failing issue

Example fix

// before
if err := c.store.UpdateIssue(ctx, issueID, updates, "compactor"); err != nil {
	return fmt.Errorf("failed to update issue: %w", err)
}
// after
if err := c.store.UpdateIssue(ctx, issueID, updates, "compactor"); err != nil {
	if errors.Is(err, types.ErrNotFound) {
		return fmt.Errorf("issue %s deleted during compaction: %w", issueID, err)
	}
	return fmt.Errorf("failed to update issue %s: %w", issueID, err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: verify the issue exists and store is healthy before compacting
if _, err := store.GetIssue(ctx, issueID); err != nil {
	return fmt.Errorf("issue %s not available for compaction: %w", issueID, err)
}

Try / catch

if err := client.CompactTier1(ctx, issueID); err != nil {
	var storeErr *store.Error
	if errors.As(err, &storeErr) {
		log.Printf("storage failure during compaction: %v", storeErr)
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/ea20fcb2f66c6d1e. Report an issue: GitHub.