alibaba/open-code-review · error

review failed

Error message

review failed: %w

What it means

The review execution itself returned an error (runErr). executeReviewContext wraps it as 'review failed:' before joining it with any emit error; the manifest (if constructed) has still been emitted so partial results are available. Exit status will be non-zero.

Solutions

  1. Read the wrapped runErr for the underlying failure (LLM errors, git errors, session delivery failures)
  2. Check stderr for the retry report and session ID; retry with --resume <session-id> if a session was created
  3. If only some items failed, the manifest is still published with partial coverage; inspect it to see which items failed
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cmd/opencodereview/review_cmd.go:313 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at cmd/opencodereview/review_cmd.go:313

		// it whenever it ran (which it does even for a fully failed run, since a
		// failed manifest is still publishable), so the failure-usage path gets it
		// only when that call was skipped entirely.
		failureReport := retryReport
		if emitted {
			failureReport = nil
		}
		emitFailureUsage(ag, time.Since(startTime), opts.outputFormat, llmIdentity, failureReport)
		if id := ag.SessionID(); id != "" {
			fmt.Fprintf(os.Stderr, "[ocr] Session: %s (retry with: --resume %s)\n", id, id)
		}
		return errors.Join(resultErr, emitErr)
	}
	return emitErr
}

func reviewResultError(runErr error, manifest *session.RunManifest) error {
	if runErr != nil {
		return fmt.Errorf("review failed: %w", runErr)
	}
	if manifest != nil && manifest.TerminalState == session.StateFailed {
		// The exit contract is: non-zero only for a run-level failure, or when
		// every selected item failed. Any usable coverage — even incomplete — exits
		// 0, so complete/partial/skipped all succeed and only failed lands here.
		// That makes a budget stop exit 0 whenever anything was covered (it is a
		// controlled truncation recording no run_failure) and non-zero only when
		// the cap left nothing covered at all. Partial results are published
		// regardless: runReview emits the frozen manifest before this error decides
		// the exit status.
		//
		// Reasons stored in the manifest already went through sanitizeReason, so
		// they are safe to echo on stderr.
		if rf := manifest.RunFailure; rf != nil {
			if rf.Reason != "" {
				return fmt.Errorf("review failed (%s): %s", rf.Classification, rf.Reason)
			}
			return fmt.Errorf("review failed (%s)", rf.Classification)

View on GitHub (pinned to 5cf97d0d15)