micro/go-micro · error

flow: Verify requires a grader

Error message

flow: Verify requires a grader

What it means

flow.Verify requires both a body step and a grader; this error is returned at run time when the grader function is nil. Without a grader the verification loop cannot decide pass/fail, so the input State is returned unchanged with this error. Like the missing-body error, it signals a misconfigured Verify call.

Source

Thrown at flow/verify.go:72

// "verification_passed": false, "verification_feedback", and
// "verification_attempts".
func Verify(body StepFunc, grader Grader, opts ...VerifyOption) StepFunc {
	o := VerifyOptions{MaxAttempts: 2, FeedbackField: "feedback"}
	for _, op := range opts {
		op(&o)
	}
	if o.MaxAttempts <= 0 {
		o.MaxAttempts = 2
	}
	if o.FeedbackField == "" {
		o.FeedbackField = "feedback"
	}
	return func(ctx context.Context, in State) (State, error) {
		if body == nil {
			return in, fmt.Errorf("flow: Verify requires a body step")
		}
		if grader == nil {
			return in, fmt.Errorf("flow: Verify requires a grader")
		}
		cur := in
		last := in
		feedback := ""
		for attempt := 1; attempt <= o.MaxAttempts; attempt++ {
			if err := ctx.Err(); err != nil {
				return last, err
			}
			if feedback != "" {
				var err error
				cur, err = stateWithField(cur, o.FeedbackField, feedback)
				if err != nil {
					return last, err
				}
			}
			out, err := body(ctx, cur)
			if err != nil {
				return last, fmt.Errorf("verify attempt %d: %w", attempt, err)

View on GitHub (pinned to 24529f1404)

Solutions

  1. Pass a non-nil Grader (e.g. flow.LLMGrader(rubric) or a custom func) as the second argument to Verify.
  2. Ensure the flow model is configured if using LLMGrader, since a nil grader and a failing grader setup are common confusions.
  3. Validate grader != nil before constructing the flow to surface the problem at build time.

Example fix

// before
return flow.Verify(body, nil)
// after
grader := flow.LLMGrader("output must contain a summary")
return flow.Verify(body, grader)
Defensive patterns

Strategy: validation

Validate before calling

if grader == nil {
    return nil, errors.New("verify: grader must be configured")
}
return flow.Verify(body, grader), nil

Type guard

func graderConfigured(g flow.Grader) bool { return g != nil }

Try / catch

out, err := verifiedStep(ctx, in)
if err != nil && strings.Contains(err.Error(), "Verify requires a grader") {
    // misconfiguration: supply a grader before re-running
}

Prevention

When it happens

Trigger: Calling flow.Verify(body, nil), or passing a grader variable that was never assigned (e.g. LLMGrader(...) result discarded or a conditional that skipped assignment).

Common situations: Choosing a grader from config where no grader type was specified; a stub returning nil during development; renaming a grader variable and leaving the Verify call pointing at a nil zero-value.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/c735d462f1fe6915. Report an issue: GitHub.