{"record":{"id":"dc358820847e1af2","repo":"gastownhall/beads","slug":"failed-to-read-jsonl-file-s-w","errorCode":null,"errorMessage":"failed to read JSONL file %s: %w","messagePattern":"failed to read JSONL file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import_shared.go","lineNumber":988,"sourceCode":"\n// importFromLocalJSONL imports issues (and memories) from a local JSONL file on disk\n// into the Dolt store. Returns the number of issues imported and any error.\n// This is a convenience wrapper around importFromLocalJSONLFull.\nfunc importFromLocalJSONL(ctx context.Context, store storage.DoltStorage, localPath string) (int, error) {\n\tresult, err := importFromLocalJSONLFull(ctx, store, localPath)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn result.Issues, nil\n}\n\n// parseJSONLFile reads a JSONL file and returns parsed issues and config\n// entries (memories). Pure function — no store I/O.\nfunc parseJSONLFile(path string) ([]*types.Issue, map[string]string, error) {\n\t//nolint:gosec // G304: path from user-provided CLI argument\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to read JSONL file %s: %w\", path, err)\n\t}\n\n\tscanner := bufio.NewScanner(strings.NewReader(string(data)))\n\t// Allow up to 64MB per line for large descriptions\n\tscanner.Buffer(make([]byte, 0, 1024*1024), 64*1024*1024)\n\tvar issues []*types.Issue\n\tconfigEntries := make(map[string]string)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Peek at the record to check for _type field\n\t\tvar peek map[string]json.RawMessage\n\t\tif err := json.Unmarshal([]byte(line), &peek); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"failed to parse JSONL line: %w\", err)","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import_shared.go#L970-L1006","documentation":"parseJSONLFile reads the import file from disk before any parsing. If os.ReadFile fails (missing file, permission denied, path is a directory, I/O error), the import aborts with `failed to read JSONL file <path>: <cause>`. This is a pre-parse, filesystem-level failure — the JSON content itself is never examined.","triggerScenarios":"`bd import path.jsonl` where the file doesn't exist, the path is wrong relative to the current directory, the file lacks read permissions, or the path points to a directory instead of a file.","commonSituations":"Typo in filename or running from a different working directory; file deleted or renamed after a previous export; exporting to a path and importing a stale/incorrect path in scripts; permissions changed by a sync/backup tool.","solutions":["Verify the path exists and is readable: `ls -la <path>` and check you're in the intended working directory.","Use an absolute path or correct the relative path.","Fix file permissions (`chmod u+r`) or re-export the JSONL from the source repository.","If a script does the export-then-import, ensure the export step succeeded before importing."],"exampleFix":"// before\nbd import export.jsonl   # failed to read JSONL file export.jsonl: no such file or directory\n// after\nls -la; bd import /absolute/path/to/export.jsonl   # correct, existing path","handlingStrategy":"validation","validationCode":"func requireReadableJSONL(path string) error {\n    fi, err := os.Stat(path)\n    if err != nil { return err }\n    if fi.IsDir() { return fmt.Errorf(\"%s is a directory\", path) }\n    f, err := os.Open(path)\n    if err != nil { return err }\n    return f.Close()\n}\n// call requireReadableJSONL(path) before bd import","typeGuard":null,"tryCatchPattern":"if err := runImport(path); err != nil {\n    if strings.Contains(err.Error(), \"failed to read JSONL file\") {\n        return fmt.Errorf(\"check the import path (exists? readable? correct cwd): %w\", err)\n    }\n    return err\n}","preventionTips":["Use absolute paths in scripts; don't rely on cwd.","`ls -la <path>` before scripted imports.","Regenerate the export if the file is missing rather than reusing a stale path.","Check permissions after sync/backup tools touch the file."],"tags":["filesystem","import","jsonl","path"],"backgroundTag":"file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}