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

  1. If the error is bufio.ErrTooLong, increase the buffer: scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) or split oversized lines.
  2. Check disk health / remount the filesystem; verify the file isn't changing during load.
  3. 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

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


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/a9d925cecf6f8924. Report an issue: GitHub.