{"record":{"id":"f3a7e01bc1454423","repo":"gastownhall/beads","slug":"migration-failed-w","errorCode":null,"errorMessage":"migration failed: %w","messagePattern":"migration failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/bd/migrate_issues.go","lineNumber":189,"sourceCode":"\t// Step 5: Build migration plan\n\tplan := buildMigrationPlan(candidates, migrationSet, dependencyStats, orphans, p.from, p.to)\n\n\t// Step 6: Display plan\n\tif err := displayMigrationPlan(plan, p.dryRun); err != nil {\n\t\treturn err\n\t}\n\n\t// Step 7: Execute migration if not dry-run\n\tif !p.dryRun {\n\t\tif !p.yes && !jsonOutput {\n\t\t\tif !confirmMigration(plan) {\n\t\t\t\tfmt.Println(\"Migration canceled\")\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\tif err := executeMigration(ctx, s, migrationSet, p.to); err != nil {\n\t\t\treturn fmt.Errorf(\"migration failed: %w\", err)\n\t\t}\n\n\t\tif jsonOutput {\n\t\t\treturn outputJSON(map[string]interface{}{\n\t\t\t\t\"success\": true,\n\t\t\t\t\"message\": fmt.Sprintf(\"Migrated %d issues from %s to %s\", len(migrationSet), p.from, p.to),\n\t\t\t\t\"plan\":    plan,\n\t\t\t})\n\t\t}\n\t\tfmt.Printf(\"\\n✓ Successfully migrated %d issues from %s to %s\\n\", len(migrationSet), p.from, p.to)\n\t}\n\n\treturn nil\n}\n\nfunc validateRepos(ctx context.Context, s storage.DoltStorage, from, to string, strict bool) error {\n\t// migrate-issues is a round-trip path — opt out of BEADS_MAX_ROWS\n\t// (designer §4.1) so a misconfigured env doesn't abort migration.","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/migrate_issues.go#L171-L207","documentation":"This error wraps failures from executeMigration, the step that actually rewrites each issue's repo field from p.from to p.to after the user confirms the plan. It means the write phase of the migration failed partway, potentially leaving some issues migrated and others not. The wrapped error carries the storage-level cause.","triggerScenarios":"executeMigration(ctx, s, migrationSet, p.to) returns an error after plan confirmation, while batch-updating issue repo assignments.","commonSituations":"Disk full or database write failure mid-batch; another bd process mutating the same rows concurrently; context cancellation (Ctrl-C) during a long migration; transaction size limits on very large migration sets.","solutions":["Inspect the wrapped error to see how far the migration got","Re-run the same command — candidates are re-derived and already-migrated issues no longer match --from, making the retry idempotent","Restore from the Dolt history / backup if a partial state is unacceptable","Migrate in smaller filter batches to keep each write transaction small"],"exampleFix":"// before: one giant batch can fail mid-way\nif err := executeMigration(ctx, s, migrationSet, p.to); err != nil {\n    return fmt.Errorf(\"migration failed: %w\", err)\n}\n// after: migrate in filtered batches so retries stay small\ncmd bd migrate-issues --from old --to new --label backend\ncmd bd migrate-issues --from old --to new --label frontend","handlingStrategy":"try-catch","validationCode":"// back up before executing\nbd dolt push   # or otherwise snapshot the database\nbd migrate-issues --from old --to new --dry-run  # confirm the plan size is sane","typeGuard":null,"tryCatchPattern":"if err := runMigrate(); err != nil {\n    if strings.Contains(err.Error(), \"migration failed\") {\n        log.Printf(\"migration aborted mid-write: %v — retry is idempotent (already-migrated issues no longer match --from)\", errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Snapshot the database (bd dolt push / backup) before executing","Migrate in small filter batches to limit partial-write blast radius","Never Ctrl-C mid-execution; let the batch finish","Re-run the same command after a failure — it is idempotent"],"tags":["cli","migrations","data-loss"],"backgroundTag":"migration-partial-write-failure","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}