{"record":{"id":"3b1be79cde636142","repo":"gastownhall/beads","slug":"import-failed-w-3b1be7","errorCode":null,"errorMessage":"import failed: %w","messagePattern":"import failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import_proxied_server.go","lineNumber":145,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\t// THE BATCH: rows, memories and the issue_prefix reconciliation in one\n\t// transaction, one history entry. The prefix sync runs even when the\n\t// batch is otherwise empty, exactly as the classic path's post-commit\n\t// sync does (be-llaf; config.yaml is authoritative, not a rename).\n\tbatch, err := importer.ImportBatch(ctx, publicops.ImportBatchRequest{\n\t\tActor:                getActorWithGit(),\n\t\tIssues:               issues,\n\t\tMemories:             memoryEntries,\n\t\tAllowStale:           importAllowStale,\n\t\tSkipPrefixValidation: true,\n\t\tSyncIssuePrefix:      config.GetString(\"issue-prefix\"),\n\t\tSource:               filepath.Base(source),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"import failed: %w\", err)\n\t}\n\tresult.Memories = batch.MemoriesImported\n\n\tif len(issues) > 0 {\n\t\tstaleRejectedSet := make(map[string]struct{}, len(batch.StaleRejectedIDs))\n\t\tfor _, id := range batch.StaleRejectedIDs {\n\t\t\tstaleRejectedSet[id] = struct{}{}\n\t\t}\n\t\tskippedDependencies := make([]string, 0, len(batch.SkippedDependencies))\n\t\tfor _, dep := range batch.SkippedDependencies {\n\t\t\tskippedDependencies = append(skippedDependencies, fmt.Sprintf(\"%s -> %s: %s\", dep.IssueID, dep.DependsOnID, dep.Reason))\n\t\t}\n\t\tapplyImportOutcome(&result, assembleImportResult(issues, staleSkippedIDs, changePlan, staleRejectedSet, skippedDependencies))\n\t} else {\n\t\tresult.Skipped += len(staleSkippedIDs)\n\t\tresult.StaleSkippedIDs = append(result.StaleSkippedIDs, staleSkippedIDs...)\n\t}\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import_proxied_server.go#L127-L163","documentation":"The main batch write of a proxied-server import failed inside the single unit of work that commits issue rows, memories, and prefix sync. Because the proxied path uses ONE commit per invocation, a failure here means the entire import rolled back atomically — no partial rows are left behind. The wrapped cause carries the underlying storage error.","triggerScenarios":"`bd import` via proxied server where the Importer's batch CreateIssuesWithFullOptions call returns an error: stale upserts rejected by RejectStaleUpserts (when staleness is not allowed), connectivity loss, constraint conflicts, or quota/permission failures.","commonSituations":"Remote Dolt server connection dropped mid-import; importing rows that are stale relative to local updates (with stale imports disallowed); schema/prefix validation issues; storage lock contention on a busy shared database.","solutions":["Read the wrapped cause to identify the concrete storage failure.","If the cause is stale-row rejection, re-export a fresh JSONL or pass the flag that allows stale imports (--allow-stale).","Verify connectivity to the proxied server and retry — since the import is atomic, simply re-running is safe.","Check database permissions/locks if the cause indicates write denial or lock timeouts.","Validate the issue-prefix configuration matches the incoming records' prefixes."],"exampleFix":"// before\nbd import issues.jsonl   # import failed: stale upsert rejected: bd-123\n// after\nbd import --allow-stale issues.jsonl   # or re-export fresh data and retry","handlingStrategy":"retry","validationCode":"// validate prefixes and staleness expectations before importing\nfor _, iss := range issues {\n    if prefix := strings.SplitN(iss.ID, \"-\", 2)[0]; prefix != expectedPrefix {\n        return fmt.Errorf(\"record %s has mismatched prefix %s\", iss.ID, prefix)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := runImportRecordsProxied(ctx, issues, memories, source)\nif err != nil {\n    // proxied import is one atomic commit: safe to retry verbatim\n    if isTransient(err) {\n        return retry(3, backoff, func() error {\n            return runImportRecordsProxied(ctx, issues, memories, source)\n        })\n    }\n    return err\n}","preventionTips":["Re-export fresh data or pass --allow-stale when source data may be older than local rows.","Use --dry-run first to surface validation and connectivity problems without writes.","Keep stable connectivity to the proxied server for the duration of the import; the import is atomic so a clean retry always works."],"tags":["import","transaction","atomicity"],"backgroundTag":"import-batch-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}