{"record":{"id":"15b6abbcb7019ecd","repo":"gastownhall/beads","slug":"error-reading-file-w","errorCode":null,"errorMessage":"error reading file: %w","messagePattern":"error reading file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/markdown.go","lineNumber":300,"sourceCode":"\n\t\t// Check for H2 (new issue)\n\t\tif matches := h2Regex.FindStringSubmatch(line); matches != nil {\n\t\t\tstate.handleH2Header(matches)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check for H3 (section within issue)\n\t\tif matches := h3Regex.FindStringSubmatch(line); matches != nil {\n\t\t\tstate.handleH3Header(matches)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Regular content line\n\t\tstate.handleContentLine(line)\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading file: %w\", err)\n\t}\n\n\treturn state.finalize()\n}\n\n// createIssuesFromMarkdown creates every issue in a markdown file as ONE act,\n// through issueops.BatchCreator. It parses the file, lints it, builds one\n// request and prints what came back; the proxied route builds the SAME request.\nfunc createIssuesFromMarkdown(ctx context.Context, in createInput) error {\n\ttemplates, err := parseMarkdownFile(in.markdownFile)\n\tif err != nil {\n\t\treturn HandleError(\"parsing markdown file: %v\", err)\n\t}\n\tif len(templates) == 0 {\n\t\treturn HandleError(\"no issues found in markdown file\")\n\t}\n\tif store == nil {\n\t\treturn HandleErrorWithHint(\"database not initialized\", diagHint())","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/markdown.go#L282-L318","documentation":"After scanning lines, parseMarkdownFile checks scanner.Err() and wraps any read failure as \"error reading file: <os error>\". Unlike open errors, this fires mid-scan — the file opened fine but reading its contents hit an I/O problem.","triggerScenarios":"The bufio scanner hits an I/O error while reading (disk error, file truncated/changed on a network mount, device removed), after os.Open succeeded.","commonSituations":"Unstable network filesystems (NFS/SMB dropouts); file being rewritten concurrently by another process; failing disk or removable media pulled mid-read.","solutions":["Re-run the import — transient I/O errors often clear","Copy the file to local disk first and import the local copy","Check dmesg/mount status for disk or NFS problems if reproducible","Stop concurrent writers so the file is not mutated during the scan"],"exampleFix":"// before\nparseMarkdownFile(\"/mnt/nfs/issues.md\")   // flaky NFS\n// after\ncp /mnt/nfs/issues.md /tmp/issues.md && parseMarkdownFile(\"/tmp/issues.md\")","handlingStrategy":"retry","validationCode":"// ensure stable local copy before import\ncp /network/issues.md /tmp/issues.md","typeGuard":null,"tryCatchPattern":"err := runImport(path)\nfor i := 0; err != nil && strings.Contains(err.Error(), \"error reading file\") && i < 2; i++ {\n\ttime.Sleep(time.Second)\n\terr = runImport(path)\n}","preventionTips":["Copy network-mounted files to local disk before import","Avoid concurrent writes to the file during import","Monitor disk/NFS health if errors recur"],"tags":["filesystem","io","scan"],"backgroundTag":"file-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}