alibaba/open-code-review · error

resume session %q is missing review mode metadata

Error message

resume session %q is missing review mode metadata

What it means

ResumeState.ValidateOptions rejects when the replayed session state carries an empty ReviewMode — i.e. the prior session's JSONL never recorded a session_start with reviewMode metadata. The library cannot verify mode compatibility without it.

Source

Thrown at internal/session/resume.go:282

	}
	return out
}

// ValidateOptions verifies that this session can be resumed in the requested
// review mode at all. It deliberately does not compare the ref text the user
// typed: `abc1234` and `abc1234def` can name the same commit while a ref whose
// name did not change can name a new one, so ref spellings are neither
// sufficient nor necessary evidence about the input. ValidateResume compares the
// resolved input identity instead.
func (s *ResumeState) ValidateOptions(opts SessionOptions) error {
	if s == nil {
		return nil
	}
	if opts.ReviewMode == "" || opts.ReviewMode == ReviewModeWorkspace {
		return fmt.Errorf("resume requires --from/--to or --commit; workspace resume is not supported")
	}
	if s.ReviewMode == "" {
		return fmt.Errorf("resume session %q is missing review mode metadata", s.SessionID)
	}
	if s.ReviewMode != opts.ReviewMode {
		return fmt.Errorf("resume session review mode %q does not match current mode %q", s.ReviewMode, opts.ReviewMode)
	}
	if opts.ReviewMode != ReviewModeRange && opts.ReviewMode != ReviewModeCommit {
		return fmt.Errorf("resume mode %q is not supported", opts.ReviewMode)
	}
	return nil
}

// ValidateScanOptions verifies that the previous session was a full-file scan.
func (s *ResumeState) ValidateScanOptions(scanPaths []string) error {
	if s == nil {
		return nil
	}
	if s.ReviewMode == "" {
		return fmt.Errorf("resume session %q is missing review mode metadata", s.SessionID)
	}

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Start a fresh review for that old session; legacy files carry no mode metadata to validate
  2. Regenerate a session by running a new review in the desired mode, then resume that
  3. Do not hand-edit the JSONL to inject reviewMode — fingerprints were computed under unknown semantics
Defensive patterns

Strategy: validation

Validate before calling

// peek the first session_start record before resuming legacy files
hasMode := false
for _, line := range firstLines(path, 5) {
	var rec map[string]any
	if json.Unmarshal(line, &rec) == nil && rec["reviewMode"] != nil { hasMode = true; break }
}
if !hasMode { /* legacy file: don't resume */ }

Try / catch

if err := state.ValidateOptions(opts); err != nil {
	if strings.Contains(err.Error(), "missing review mode metadata") {
		return runFresh(opts) // legacy session
	}
	return err
}

Prevention

When it happens

Trigger: Resuming a legacy session file written before reviewMode was persisted in session_start records, or a session file whose only records are checkpoints with no session_start line (truncated very early).

Common situations: Upgrading open-code-review across versions and resuming a pre-metadata session file; a session file truncated before its first session_start record was flushed.

Related errors


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