{"record":{"id":"39430a26a3281a6c","repo":"gastownhall/beads","slug":"failed-to-scan-jsonl-w-39430a","errorCode":null,"errorMessage":"failed to scan JSONL: %w","messagePattern":"failed to scan JSONL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import.go","lineNumber":296,"sourceCode":"\t\t\t\t\tmemories = append(memories, mem)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tvar issue types.Issue\n\t\tif err := json.Unmarshal([]byte(line), &issue); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse issue from JSONL: %w\", err)\n\t\t}\n\t\tif issue.Status == \"tombstone\" {\n\t\t\tcontinue\n\t\t}\n\t\tapplyImportWispPlane(peek, &issue)\n\t\tissue.SetDefaults()\n\t\tissues = append(issues, &issue)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to scan JSONL: %w\", err)\n\t}\n\treturn issues, memories, nil\n}\n\n// runImportRecordsClassic is the classic (embedded/direct store) import\n// pipeline over the parsed records: dedup, dry-run classification, memory\n// writes, the batch issue import, the final commit and the issue_prefix\n// reconciliation.\nfunc runImportRecordsClassic(ctx context.Context, issues []*types.Issue, memories []memoryRecord, source string) error {\n\t// Dedup: skip issues whose title matches an existing open issue\n\tdedupHits := 0\n\tif importDedup && len(issues) > 0 {\n\t\tissues, dedupHits = filterDuplicatesByTitle(ctx, store, issues)\n\t}\n\n\tresult := importResultJSON{\n\t\tSource:    source,\n\t\tDedupHits: dedupHits,","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import.go#L278-L314","documentation":"The bufio.Scanner reading the JSONL stream hit an I/O or buffer error while iterating lines (not a JSON syntax problem — those fail earlier). scanner.Err() is non-nil, so the underlying read itself failed.","triggerScenarios":"`bd import -` reading from a pipe/stdin that errors mid-stream (broken pipe, closed fd), a file that disappears or has permission issues mid-read, or a single line exceeding bufio.Scanner's default 64KB max token size.","commonSituations":"Piping huge exports through stdin; network filesystem dropouts; extremely long single-line records produced by minified exports.","solutions":["Check that the input source (file/stdin pipe) is readable and stays available during import","If lines exceed ~64KB, split records or re-export with stable formatting instead of one giant line","Retry the pipe transfer if the producer crashed mid-stream","Import from a local file rather than a flaky pipe: `bd import file.jsonl`"],"exampleFix":"// before\ncat huge.jsonl | bd import -   # bufio: token too long\n// after\nbd export -o split.jsonl   # canonical multi-line export\nbd import split.jsonl","handlingStrategy":"fallback","validationCode":"test -r data.jsonl && [ $(awk '{print length}' data.jsonl | sort -n | tail -1) -lt 60000 ]","typeGuard":null,"tryCatchPattern":"if ! bd import data.jsonl 2>err.log; then\n  grep 'failed to scan JSONL' err.log && bd import data.jsonl   # retry after source check\nfi","preventionTips":["Import from local files, not long-lived pipes over unstable links","Keep individual JSONL records below bufio.Scanner's ~64KB line limit","Ensure the input file is not being written/truncated while importing","Verify producer processes finish writing before the import starts"],"tags":["io","jsonl","cli"],"backgroundTag":"stream-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}