{"record":{"id":"330125428c281218","repo":"gastownhall/beads","slug":"failed-to-set-issue-prefix-from-imported-issues","errorCode":null,"errorMessage":"failed to set issue_prefix from imported issues: %w","messagePattern":"failed to set issue_prefix from imported issues: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import_shared.go","lineNumber":1166,"sourceCode":"\tresult := &importLocalResult{}\n\n\t// Import memories\n\tfor key, value := range configEntries {\n\t\tif err := store.SetConfig(ctx, key, value); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to import config %q: %w\", key, err)\n\t\t}\n\t\tresult.Memories++\n\t}\n\n\t// Import issues\n\tif len(issues) > 0 {\n\t\t// Auto-detect prefix from first issue if not already configured\n\t\tconfiguredPrefix, err := store.GetConfig(ctx, \"issue_prefix\")\n\t\tif err == nil && strings.TrimSpace(configuredPrefix) == \"\" {\n\t\t\tfirstPrefix := utils.ExtractIssuePrefix(issues[0].ID)\n\t\t\tif firstPrefix != \"\" {\n\t\t\t\tif err := store.SetConfig(ctx, \"issue_prefix\", firstPrefix); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to set issue_prefix from imported issues: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\topts := ImportOptions{\n\t\t\tSkipPrefixValidation: true,\n\t\t\tConflictSkip:         conflictSkip,\n\t\t}\n\t\timportResult, err := importIssuesCore(ctx, \"\", store, issues, opts)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresult.Issues = importResult.Created\n\t}\n\n\treturn result, nil\n}\n","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import_shared.go#L1148-L1184","documentation":"After importing issues, if no issue_prefix is configured, importFromLocalJSONLWithOpts auto-detects it from the first imported issue's ID (utils.ExtractIssuePrefix) and writes it via store.SetConfig. This error wraps a failure of that SetConfig write — the issues imported, but the prefix could not be recorded.","triggerScenarios":"JSONL import where issues[0].ID has a detectable prefix (e.g. \"bd-1\"), store.GetConfig(\"issue_prefix\") returned empty, and the subsequent SetConfig(\"issue_prefix\", prefix) fails against the Dolt store (DB error, read-only gateway, locked DB).","commonSituations":"Same DB-level problems as config import: read-only hosted credentials, Dolt server down, disk full; importing into a database provisioned without a prefix (which in gateway mode is normally rejected earlier).","solutions":["Read the wrapped %w cause for the underlying DB error","Set the prefix manually once the DB is writable: `bd config set issue_prefix <prefix>`","Check gateway credentials/permissions if using a hosted database","Ensure the Dolt server is running and the data dir has free space, then re-run"],"exampleFix":"// before: auto-detect write fails on read-only gateway\n// after: provisioned prefix should already exist server-side; verify with\nbd config get issue_prefix  # if empty, re-provision server-side or use writable credentials","handlingStrategy":"try-catch","validationCode":"prefix, err := store.GetConfig(ctx, \"issue_prefix\")\nif err != nil { return err }\nif strings.TrimSpace(prefix) == \"\" {\n    // prefix will be auto-set from issues[0]; ensure the store is writable first\n    if err := store.SetConfig(ctx, \"issue_prefix\", \"_probe\"); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"if err := store.SetConfig(ctx, \"issue_prefix\", firstPrefix); err != nil {\n    log.Printf(\"could not persist auto-detected prefix %q: %v\", firstPrefix, err)\n    return err\n}","preventionTips":["Provision issue_prefix server-side before gateway imports so auto-detect never runs","Check writability of the store before importing a JSONL with issues","Keep the Dolt server healthy and the disk non-full","Prefer running imports from a rig with write credentials"],"tags":["database","config","issue-prefix","import","dolt"],"backgroundTag":"config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}