micro/go-micro · error
flow: Verify requires a body step
Error message
flow: Verify requires a body step
What it means
flow.Verify wraps a body step with a retry-and-grade loop; this error is returned at run time when the wrapped body step is nil. Verify cannot retry a step that does not exist, so the returned State is passed through unchanged with this error. It indicates a programming mistake in how Verify was called, not a runtime failure of the body itself.
Source
Thrown at flow/verify.go:69
// JSON field named "feedback" (or VerifyFeedbackField). When all attempts fail,
// it returns the last output without error, annotated with verification fields so
// the run can keep the bounded failure outcome in its state:
// "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
}
}View on GitHub (pinned to 24529f1404)
Solutions
- Pass a non-nil Step function as the body argument to flow.Verify.
- Guard the call site: only wrap with Verify when the body was successfully constructed.
- Fail fast at construction time by checking body != nil before calling Verify instead of at run time.
Example fix
// before
var body flow.StepFunc // nil
return flow.Verify(body, grader)
// after
if body == nil {
return nil, fmt.Errorf("body step not configured")
}
return flow.Verify(body, grader) Defensive patterns
Strategy: validation
Validate before calling
if body == nil {
return nil, errors.New("verify: body step must be configured")
}
return flow.Verify(body, grader), nil Type guard
func bodyConfigured(f flow.StepFunc) bool { return f != nil } Try / catch
out, err := verifiedStep(ctx, in)
if err != nil && strings.Contains(err.Error(), "Verify requires a body step") {
// configuration bug: fix flow wiring, not a runtime condition
} Prevention
- Never declare a StepFunc variable without assigning it before Verify.
- Make step construction functions return (StepFunc, error) so nil bodies surface early.
- Cover every Verify wiring with a smoke test that executes the flow once.
When it happens
Trigger: Calling flow.Verify(nil, grader) or Verify with a body variable that was declared but never assigned, so the returned step function returns "flow: Verify requires a body step" on first execution.
Common situations: Conditionally assigning the body step and a branch leaving it nil; passing the result of a factory that can return nil; refactoring that removed the body but kept the Verify wrapper.
Related errors
- flow: Verify requires a grader
- verify attempt %d: %w
- verify grade attempt %d: %w
- flow: LLMGrader requires a flow model (set Provider/APIKey)
- LLM step requires a flow model (set Provider/APIKey)
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/7702dfe48ed99419.
Report an issue: GitHub.