{"record":{"id":"4ce660abec09ffca","repo":"gastownhall/beads","slug":"import-failed-w","errorCode":null,"errorMessage":"import failed: %w","messagePattern":"import failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import.go","lineNumber":344,"sourceCode":"\t\tapplyImportDryRunClassification(&result, classification)\n\t\treturn renderImportDryRun(result, len(memories), source, dedupHits)\n\t}\n\n\t// Import memories\n\tfor _, mem := range memories {\n\t\tstorageKey := kvPrefix + memoryPrefix + mem.Key\n\t\tif err := store.SetConfig(ctx, storageKey, mem.Value); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to import memory %q: %w\", mem.Key, err)\n\t\t}\n\t\tresult.Memories++\n\t}\n\n\t// Import issues\n\tif len(issues) > 0 {\n\t\topts := ImportOptions{SkipPrefixValidation: true, AllowStale: importAllowStale}\n\t\timportResult, err := importIssuesCore(ctx, \"\", store, issues, opts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"import failed: %w\", err)\n\t\t}\n\t\tapplyImportOutcome(&result, importResult)\n\t}\n\n\tif result.Created > 0 || result.Memories > 0 {\n\t\tcommitMsg := fmt.Sprintf(\"bd import: %d issues\", result.Created)\n\t\tif result.Memories > 0 {\n\t\t\tcommitMsg += fmt.Sprintf(\", %d memories\", result.Memories)\n\t\t}\n\t\tcommitMsg += fmt.Sprintf(\" from %s\", filepath.Base(source))\n\t\tif err := store.Commit(ctx, commitMsg); err != nil {\n\t\t\t// An import can be a working-set no-op: re-importing an\n\t\t\t// identical snapshot, or equal-timestamp rows whose guarded\n\t\t\t// upsert kept every local column (bd-hj85c).\n\t\t\tif !strings.Contains(err.Error(), \"nothing to commit\") {\n\t\t\t\treturn fmt.Errorf(\"commit: %w\", err)\n\t\t\t}\n\t\t}","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import.go#L326-L362","documentation":"The core issue-writing pipeline importIssuesCore failed during classic import; the whole operation is reported as `import failed: <cause>`. This covers dedup/prefix validation, guarded upserts, and any store-level error raised while writing issue rows.","triggerScenarios":"`bd import` with issues where importIssuesCore errors: prefix validation failure (mismatched issue prefixes vs configured prefix, bypassed here only via SkipPrefixValidation on other paths), stale imports without AllowStale, constraint violations, or store write errors.","commonSituations":"Importing an export from a repo with a different issue_prefix; importing stale snapshots over a database that advanced; duplicate ID conflicts with different content; database lock contention.","solutions":["Read the wrapped inner error after `import failed:` for the specific cause","Re-export from source with `bd export` so records match the current schema/prefix","Use `bd import --dry-run` first to classify what would fail before committing","If staleness is the cause, re-run with `--allow-stale` after confirming the snapshot is acceptable"],"exampleFix":"// before\nbd import old-export.jsonl   # import failed: prefix mismatch (bd- vs acme-)\n// after\n# fix prefix in records to match local config.yaml issue_prefix\nbd import --dry-run old-export.jsonl && bd import old-export.jsonl","handlingStrategy":"try-catch","validationCode":"bd import --dry-run data.jsonl   # classify before committing\njq -e '.issue_prefix' .beads/config.yaml >/dev/null 2>&1 || bd config get issue_prefix","typeGuard":null,"tryCatchPattern":"if ! bd import data.jsonl 2>err.log; then\n  grep -o 'import failed: .*' err.log   # read inner cause (prefix, staleness, dup)\nfi","preventionTips":["Always dry-run before real imports","Align issue_prefix across repos before transferring exports","Re-export fresh data instead of replaying old snapshots","Read the wrapped cause under 'import failed:' before changing flags"],"tags":["cli","import","validation"],"backgroundTag":"import-pipeline-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}