{"record":{"id":"acdf3b471b0b6125","repo":"micro/go-micro","slug":"verify-grade-attempt-d-w","errorCode":null,"errorMessage":"verify grade attempt %d: %w","messagePattern":"verify grade attempt (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"flow/verify.go","lineNumber":95,"sourceCode":"\t\tfor attempt := 1; attempt <= o.MaxAttempts; attempt++ {\n\t\t\tif err := ctx.Err(); err != nil {\n\t\t\t\treturn last, err\n\t\t\t}\n\t\t\tif feedback != \"\" {\n\t\t\t\tvar err error\n\t\t\t\tcur, err = stateWithField(cur, o.FeedbackField, feedback)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn last, err\n\t\t\t\t}\n\t\t\t}\n\t\t\tout, err := body(ctx, cur)\n\t\t\tif err != nil {\n\t\t\t\treturn last, fmt.Errorf(\"verify attempt %d: %w\", attempt, err)\n\t\t\t}\n\t\t\tlast = out\n\t\t\tpass, fb, err := grader(ctx, out)\n\t\t\tif err != nil {\n\t\t\t\treturn last, fmt.Errorf(\"verify grade attempt %d: %w\", attempt, err)\n\t\t\t}\n\t\t\tif pass {\n\t\t\t\treturn stateWithVerification(out, true, fb, attempt)\n\t\t\t}\n\t\t\tfeedback = fb\n\t\t\tcur = in\n\t\t\tif attempt < o.MaxAttempts && o.Backoff > 0 {\n\t\t\t\tselect {\n\t\t\t\tcase <-time.After(o.Backoff):\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn last, ctx.Err()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn stateWithVerification(last, false, feedback, o.MaxAttempts)\n\t}\n}\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/flow/verify.go#L77-L113","documentation":"This error wraps an error returned by the grader function inside flow.Verify, annotated with the attempt number. Unlike a body error, a grader error aborts the whole verification (no retry on the next attempt), returning the last good State. The %w wrapping preserves the original grader failure.","triggerScenarios":"Any Verify run where grader(ctx, out) returns a non-nil error, producing 'verify grade attempt N: <cause>'.","commonSituations":"LLMGrader's model call fails (missing API key, quota, network); a custom grader hits a nil map/index; the grader mis-parses an unexpected State shape.","solutions":["Unwrap with errors.Is/As to find the grader's root cause (often an LLM API error).","For LLMGrader, confirm the flow model is configured (Provider/APIKey) and the API is reachable.","Make custom graders defensive: never return an error for gradable-but-failing output; return (false, feedback, nil) instead, reserving errors for true failures."],"exampleFix":"// before\nfunc myGrader(ctx context.Context, out flow.State) (bool, string, error) {\n    score, err := strconv.Atoi(out.String()) // errors on normal output\n    ...\n}\n// after\nfunc myGrader(ctx context.Context, out flow.State) (bool, string, error) {\n    score, err := strconv.Atoi(strings.TrimSpace(out.String()))\n    if err != nil {\n        return false, \"output was not a numeric score\", nil\n    }\n    return score >= 7, \"\", nil\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := step(ctx, in)\nif err != nil {\n    if cause := errors.Unwrap(err); cause != nil && isLLMError(cause) {\n        // check model config / quota, then re-run with backoff\n    }\n    return out, err\n}","preventionTips":["Make custom graders return (false, feedback, nil) for gradable failures and reserve errors for real faults.","Confirm the flow model (Provider/APIKey) is configured before runs using LLMGrader.","Keep graders pure and defensive: never index or parse without checks."],"tags":["go","flow","verify","grader","error-wrapping"],"backgroundTag":"wrapped-grader-error","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}