alibaba/open-code-review · error

emit review result: %w

Error message

emit review result: %w

What it means

Writing the run manifest/review result (JSON output) failed after execution. The design intentionally emits the manifest even when the run itself failed, so consumers always receive coverage data; this error means that emit step itself failed (serializer or writer error). It is joined with the result error so both are reported.

Source

Thrown at cmd/opencodereview/review_cmd.go:289

		// its invariant failure must not change the review's exit status.
		fmt.Fprintf(os.Stderr, "[ocr] warning: freeze retry report: %v (retry report suppressed)\n", freezeErr)
	}

	resultErr := reviewResultError(runErr, manifest)
	if resultErr != nil {
		span.SetStatus(codes.Error, resultErr.Error())
		span.RecordError(resultErr)
	}

	// A successfully constructed manifest is publishable even when execution or
	// session delivery failed. Emit it first, then return the independent process
	// error so JSON consumers retain the complete coverage diagnosis.
	var emitErr error
	emitted := manifest != nil || runErr == nil
	if emitted {
		emitErr = emitRunResult(runCtx, ag, comments, startTime, opts.outputFormat, opts.audience, q, llmIdentity, out, retryReport)
		if emitErr != nil {
			emitErr = fmt.Errorf("emit review result: %w", emitErr)
		}
	}
	if resultErr != nil {
		q.Restore()
		// The report has exactly one exit per run. emitRunResult already published
		// 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)
	}

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Inspect the wrapped error to see why emitting the manifest failed (invalid output writer, serialization error, closed stream)
  2. If using --output, verify the target path is writable
  3. The manifest is emitted before the process error is returned so JSON consumers keep the full diagnosis; re-run with output to stderr or a valid file
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cmd/opencodereview/review_cmd.go:289 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/c9c7e9f21dd87781. Report an issue: GitHub.