{"record":{"id":"92d5de484910e3ab","repo":"gastownhall/beads","slug":"failed-to-import-from-jsonl-v","errorCode":null,"errorMessage":"failed to import from JSONL: %v","messagePattern":"failed to import from JSONL: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":1823,"sourceCode":"\t\tif shouldWriteInitStateToDB(doltCfg.Gateway) {\n\t\t\tif err := store.SetMetadata(ctx, \"last_import_time\", time.Now().Format(time.RFC3339)); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to initialize last_import_time: %v\\n\", err)\n\t\t\t\t// Non-fatal - continue anyway\n\t\t\t}\n\t\t}\n\n\t\t// Import from local JSONL if requested (GH#2023).\n\t\t// This must run after the store is created and prefix is set.\n\t\tif fromJSONL {\n\t\t\tlocalJSONLPath := configuredImportJSONLPath(beadsDir)\n\t\t\tif _, statErr := os.Stat(localJSONLPath); os.IsNotExist(statErr) {\n\t\t\t\t_ = store.Close()\n\t\t\t\treturn fmt.Errorf(\"--from-jsonl specified but %s does not exist\", localJSONLPath)\n\t\t\t}\n\t\t\tissueCount, importErr := importFromLocalJSONL(ctx, store, localJSONLPath)\n\t\t\tif importErr != nil {\n\t\t\t\t_ = store.Close()\n\t\t\t\treturn fmt.Errorf(\"failed to import from JSONL: %v\", importErr)\n\t\t\t}\n\t\t\tif !quiet {\n\t\t\t\tfmt.Printf(\"  Imported %d issues from %s\\n\", issueCount, localJSONLPath)\n\t\t\t}\n\t\t}\n\n\t\t// Prompt for contributor mode if:\n\t\t// - In a git repo (needed to set beads.role config)\n\t\t// - Interactive terminal (stdin is TTY) and not --non-interactive\n\t\t// - No explicit --contributor or --team flag provided\n\t\t// - No explicit --role flag provided\n\t\tif isGitRepo() && !contributor && !team && roleFlag == \"\" && !nonInteractive && shouldPromptForRole() {\n\t\t\tpromptedContributor, err := promptContributorMode()\n\t\t\tif err != nil {\n\t\t\t\tif isCanceled(err) {\n\t\t\t\t\tfmt.Fprintln(os.Stderr, \"Setup canceled.\")\n\t\t\t\t\t_ = store.Close()\n\t\t\t\t\treturn errCanceled()","sourceCodeStart":1805,"sourceCodeEnd":1841,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L1805-L1841","documentation":"After the --from-jsonl file is found, `bd init` imports it via importFromLocalJSONL. If that import fails (parse errors, schema problems, storage write errors), bd closes the store and wraps the underlying error with this message.","triggerScenarios":"importFromLocalJSONL(ctx, store, localJSONLPath) returns a non-nil error during `bd init --from-jsonl`.","commonSituations":"Malformed JSONL (truncated file, invalid JSON on a line), issues missing required fields, duplicate/invalid dependency references, or a storage-level failure while writing the issues into the fresh Dolt database.","solutions":["Inspect the wrapped %v error to find the offending line/reason","Validate the JSONL: each line must be a complete issue JSON object (jq -c . < file)","Repair or truncate the file at the bad line, or re-export it from the source repo","Re-run bd init --from-jsonl after fixing the file"],"exampleFix":"// before (truncated last line)\n{\"id\":\"x-1\",...}\n{\"id\":\"x-2\",   <- truncated\n// after\n$ tail -1 .beads/issues.jsonl  # remove bad line\n$ bd init --from-jsonl","handlingStrategy":"validation","validationCode":"# pre-validate every line parses as JSON\nn=0; while IFS= read -r line; do\n  n=$((n+1)); printf '%s' \"$line\" | jq -e . >/dev/null || echo \"bad JSON at line $n\"\ndone < .beads/issues.jsonl","typeGuard":null,"tryCatchPattern":"bd init --from-jsonl 2>import.log || {\n  grep -F 'failed to import from JSONL' import.log\n  # fix the offending line, then retry\n}","preventionTips":["Validate JSONL with jq line-by-line before import","Ensure exports are complete (no truncated final line)","Avoid hand-editing exported issues.jsonl","Re-export from the source repo instead of patching bad data"],"tags":["jsonl","import","init","data-format"],"backgroundTag":"jsonl-import-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}