alibaba/open-code-review · error

read resume session %q: %w

Error message

read resume session %q: %w

What it means

loadResumeState wraps a non-EOF error from bufio ReadBytes while reading the session JSONL. It is thrown because an I/O failure mid-file means the checkpoint index may be incomplete and the library refuses to return a silently truncated state. EOF (normal end of file) is not an error and is excluded.

Source

Thrown at internal/session/resume.go:139

	state := &ResumeState{
		SessionID: sessionID,
		RepoDir:   repoDir,
		Items:     make(map[string]ResumeItem),
	}
	reader := bufio.NewReader(f)
	for {
		line, readErr := reader.ReadBytes('\n')
		if len(line) > 0 {
			if err := state.applyResumeLine(line); err != nil && !skipUnparseable {
				return nil, err
			}
		}
		if readErr == io.EOF {
			break
		}
		if readErr != nil {
			return nil, fmt.Errorf("read resume session %q: %w", sessionID, readErr)
		}
	}
	if state.SessionID == "" {
		state.SessionID = sessionID
	}
	return state, nil
}

// applyResumeLine folds one record into the index. It reports an unparseable
// line to the caller, which decides whether that is fatal.
func (s *ResumeState) applyResumeLine(line []byte) error {
	var rec resumeRecord
	if err := json.Unmarshal(line, &rec); err != nil {
		return fmt.Errorf("parse resume session %q: %w", s.SessionID, err)
	}

	switch rec.Type {
	case "session_start":

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Re-run the load to rule out a transient I/O failure
  2. Check disk health and free space on the volume holding ~/.opencodereview
  3. If the file is corrupted, start a fresh review; the JSONL is not repairable
  4. Copy the session file locally if HOME is on an unreliable network mount
Defensive patterns

Strategy: retry

Validate before calling

// ensure the volume holding ~/.opencodereview is writable and has space
if st, err := os.Stat(homeSessionDir); err != nil || !st.IsDir() { /* fix environment first */ }

Try / catch

state, err := session.LoadResumeState(repoDir, sessionID)
if err != nil {
	var pe *fs.PathError
	if errors.As(err, &pe) && isTransientIO(pe) { retryLoad(3) }
	return err
}

Prevention

When it happens

Trigger: Disk read error, file truncated or corrupted by a concurrent writer, I/O errors from failing storage, or the file being unreadable mid-stream (permissions changed while open).

Common situations: Machine crash or power loss left a partially written JSONL on a failing disk; NFS/network home directory dropped the connection mid-read; disk full or bad sectors.

Related errors


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/109a593f163dfc06. Report an issue: GitHub.