gastownhall/beads · error
error reading %s: %w
Error message
error reading %s: %w
What it means
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.
Source
Thrown at internal/molecules/molecules.go:201
if strings.TrimSpace(line) == "" {
continue
}
var issue types.Issue
if err := json.Unmarshal([]byte(line), &issue); err != nil {
debug.Logf("warning: %s line %d: %v", path, lineNum, err)
continue
}
// Mark as template
issue.IsTemplate = true
issue.SetDefaults()
molecules = append(molecules, &issue)
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("error reading %s: %w", path, err)
}
return molecules, nil
}
// getTownMoleculesPath returns the path to town-level molecules.jsonl
// if an orchestrator is detected via GT_ROOT environment variable.
func getTownMoleculesPath() string {
gtRoot := os.Getenv("GT_ROOT")
if gtRoot == "" {
return ""
}
// Check for orchestrator molecules file
gtPath := filepath.Join(gtRoot, ".beads", MoleculeFileName)
if _, err := os.Stat(gtPath); err == nil {
return gtPath
}View on GitHub (pinned to 71377f2769)
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.
Example fix
// before scanner := bufio.NewScanner(file) // after scanner := bufio.NewScanner(file) scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)
Defensive patterns
Strategy: try-catch
Try / catch
molecules, err := loadMoleculesFromFile(path)
if err != nil {
if strings.Contains(err.Error(), "token too long") {
return fmt.Errorf("split oversized molecule lines in %s", path)
}
return err
} Prevention
- Keep JSONL lines under 64KB or increase scanner.Buffer
- Avoid writing molecules.jsonl while a load is in progress
- Validate JSONL files after generation
When it happens
Trigger: 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).
Common situations: A molecule JSONL line larger than 64KB (very large embedded payloads); network filesystem hiccup; file rotated while being read.
Related errors
- read dependency file: %w
- failed to open %s: %w
- open batch file: %w
- open dependency file: %w
- failed to read JSONL: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/a9d925cecf6f8924.
Report an issue: GitHub.