{"record":{"id":"a9d925cecf6f8924","repo":"gastownhall/beads","slug":"error-reading-s-w","errorCode":null,"errorMessage":"error reading %s: %w","messagePattern":"error reading (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/molecules/molecules.go","lineNumber":201,"sourceCode":"\t\tif strings.TrimSpace(line) == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar issue types.Issue\n\t\tif err := json.Unmarshal([]byte(line), &issue); err != nil {\n\t\t\tdebug.Logf(\"warning: %s line %d: %v\", path, lineNum, err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Mark as template\n\t\tissue.IsTemplate = true\n\t\tissue.SetDefaults()\n\n\t\tmolecules = append(molecules, &issue)\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading %s: %w\", path, err)\n\t}\n\n\treturn molecules, nil\n}\n\n// getTownMoleculesPath returns the path to town-level molecules.jsonl\n// if an orchestrator is detected via GT_ROOT environment variable.\nfunc getTownMoleculesPath() string {\n\tgtRoot := os.Getenv(\"GT_ROOT\")\n\tif gtRoot == \"\" {\n\t\treturn \"\"\n\t}\n\n\t// Check for orchestrator molecules file\n\tgtPath := filepath.Join(gtRoot, \".beads\", MoleculeFileName)\n\tif _, err := os.Stat(gtPath); err == nil {\n\t\treturn gtPath\n\t}","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/molecules/molecules.go#L183-L219","documentation":"After scanning all lines of the molecules JSONL file, scanner.Err() is checked; any I/O error encountered mid-scan (not a parse error) is wrapped with this message. Indicates the file became unreadable or an I/O fault occurred while reading.","triggerScenarios":"bufio.Scanner hit a read error on the open file handle: disk I/O error, file truncated/deleted during read, or a line exceeding Scanner's 64KB token limit (bufio.ErrTooLong).","commonSituations":"A molecule JSONL line larger than 64KB (very large embedded payloads); network filesystem hiccup; file rotated while being read.","solutions":["If the error is bufio.ErrTooLong, increase the buffer: scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) or split oversized lines.","Check disk health / remount the filesystem; verify the file isn't changing during load.","Regenerate molecules.jsonl and retry."],"exampleFix":"// before\nscanner := bufio.NewScanner(file)\n// after\nscanner := bufio.NewScanner(file)\nscanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"molecules, err := loadMoleculesFromFile(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"token too long\") {\n        return fmt.Errorf(\"split oversized molecule lines in %s\", path)\n    }\n    return err\n}","preventionTips":["Keep JSONL lines under 64KB or increase scanner.Buffer","Avoid writing molecules.jsonl while a load is in progress","Validate JSONL files after generation"],"tags":["file-io","molecules","scanner"],"backgroundTag":"file-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}