gastownhall/beads · error

failed to load issues: %w

Error message

failed to load issues: %w

What it means

getPatrolPollutionIDs loads the full issue list via loadMaintenanceIssues to collect patrol-pollution bead IDs for deletion. Any failure from that loader (which itself tries the database then the JSONL export) is wrapped as 'failed to load issues'. Seeing this error means the underlying cause is in the wrapped message (database or JSONL read failure).

Source

Thrown at cmd/bd/doctor/maintenance.go:487

			if len(result.PatrolDigestIDs) < 3 {
				result.PatrolDigestIDs = append(result.PatrolDigestIDs, issue.ID)
			}
		case patrolIssueSessionEnded:
			result.SessionBeadCount++
			if len(result.SessionBeadIDs) < 3 {
				result.SessionBeadIDs = append(result.SessionBeadIDs, issue.ID)
			}
		}
	}

	return result
}

// getPatrolPollutionIDs returns all IDs of patrol pollution beads for deletion
func getPatrolPollutionIDs(path string) ([]string, error) {
	issues, err := loadMaintenanceIssues(path)
	if err != nil {
		return nil, fmt.Errorf("failed to load issues: %w", err)
	}

	var ids []string
	for _, issue := range issues {
		if issue == nil {
			continue
		}
		switch classifyPatrolIssue(issue.Title) {
		case patrolIssueDigest, patrolIssueSessionEnded:
			ids = append(ids, issue.ID)
		}
	}

	return ids, nil
}

// loadMaintenanceIssues loads issues for maintenance checks.
// It prefers Dolt (source of truth) and falls back to legacy JSONL for

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause: it names the database error and the JSONL error; fix that first.
  2. Verify you are pointing at the right repo (.beads directory exists with issues.jsonl).
  3. Run bd doctor to diagnose/repair the database before the pollution cleanup.
  4. If JSONL is corrupt, restore it via bd sync or regenerate it, then retry.

Example fix

// before
$ bd doctor --fix --path ./wrong-dir
Error: failed to load issues: database read failed: ...; JSONL fallback read failed: no such file
// after
$ cd /path/to/repo && bd doctor --fix
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := os.Stat(filepath.Join(path, ".beads", "issues.jsonl")); err != nil {
    return fmt.Errorf("no bd database at %s: run bd init / bd sync first", path)
}

Try / catch

ids, err := getPatrolPollutionIDs(path)
if err != nil {
    var inner error
    if errors.As(err, &inner) { /* inspect wrapped db/jsonl causes */ }
    log.Printf("skipping patrol cleanup: %v", err)
    return nil // degrade gracefully instead of failing the whole run
}

Prevention

When it happens

Trigger: loadMaintenanceIssues(path) returns an error — i.e. both the Dolt database read and the .beads/issues.jsonl fallback read failed, and that combined error is wrapped here.

Common situations: Running patrol-pollution cleanup in a directory with no initialized bd database; corrupted .beads/issues.jsonl; a Dolt server that is down or misconfigured; wrong --path pointing at a non-bd directory.

Related errors


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