{"record":{"id":"3d35e53c05af70fd","repo":"gastownhall/beads","slug":"failed-to-import-memory-q-w","errorCode":null,"errorMessage":"failed to import memory %q: %w","messagePattern":"failed to import memory %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import.go","lineNumber":334,"sourceCode":"\t}\n\n\tif importDryRun {\n\t\tresult.Memories = len(memories)\n\t\tresult.Skipped = dedupHits\n\n\t\tclassification, err := classifyDryRunImport(ctx, store, issues, importAllowStale)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"dry-run: %w\", err)\n\t\t}\n\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)","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import.go#L316-L352","documentation":"While importing memory records, store.SetConfig failed to persist a key/value pair under the internal kv prefix, so import aborts with the memory's key in the message. The wrapped error explains why the config write failed (store, transaction, or storage-level issue).","triggerScenarios":"`bd import` with memory records where store.SetConfig errors — database locked by another process, read-only filesystem/database, store closed mid-import, or storage driver failure.","commonSituations":"Two bd processes (or an agent plus a shell) writing simultaneously; running import on a read-only checkout or read-only DB file; disk-full conditions.","solutions":["Read the wrapped error after `failed to import memory` for the storage cause","Ensure no other bd process holds the DB (close other sessions, check locks)","Verify the database file and its directory are writable","Run `bd doctor` to diagnose storage health, then re-run the import"],"exampleFix":"// before\n$ bd import mem.jsonl\nfailed to import memory \"team\": database is locked\n// after\n$ bd doctor        # resolve lock / permissions\n$ bd import mem.jsonl","handlingStrategy":"retry","validationCode":"bd doctor   # verify storage writable and unlocked\n[ -w .beads/ ] && echo writable","typeGuard":null,"tryCatchPattern":"for i in 1 2 3; do\n  bd import data.jsonl && break\n  sleep $((i*i))   # back off if 'database is locked'\ndone","preventionTips":["Avoid concurrent bd sessions against the same database during import","Mount the repo and .beads directory read-write","Monitor disk space on the volume holding the database","Run bd doctor when storage errors recur"],"tags":["storage","memory-record","cli"],"backgroundTag":"kv-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}