{"record":{"id":"c0e4b2d9742dc122","repo":"alibaba/open-code-review","slug":"all-d-file-review-s-failed-check-your-llm-conf","errorCode":null,"errorMessage":"all %d file review(s) failed — check your LLM configuration and API key","messagePattern":"all (.+?) file review\\(s\\) failed — check your LLM configuration and API key","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/agent.go","lineNumber":819,"sourceCode":"\tif dispatched == 0 {\n\t\treturn a.args.CommentCollector.Comments(), nil\n\t}\n\n\tfailed := atomic.LoadInt64(&a.subtaskFailed)\n\treused := int64(0)\n\tif a.resumeInfo != nil {\n\t\treused = a.resumeInfo.ReusedFiles\n\t}\n\t// A resumed run can still have usable coverage when every newly dispatched\n\t// subtask hard-fails. Preserve the legacy all-failed error only when there is\n\t// no reused result; otherwise the manifest is partial and must exit 0.\n\tif failed > 0 && failed == dispatched && reused == 0 {\n\t\t// Even when all subtasks failed, some may have produced comments before\n\t\t// hitting the error. Return those comments instead of discarding them.\n\t\tif comments := a.args.CommentCollector.Comments(); len(comments) > 0 {\n\t\t\treturn comments, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"all %d file review(s) failed — check your LLM configuration and API key\", dispatched)\n\t}\n\n\treturn a.args.CommentCollector.Comments(), nil\n}\n\nfunc (a *Agent) recordContextFailure(err error) {\n\tif b := a.session.Manifest(); b != nil {\n\t\tvar setErr error\n\t\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t\t// A deadline truncates pending coverage without overriding completed items.\n\t\t\tsetErr = b.SetPendingFailureCause(session.FailureTimeout, \"review deadline exceeded\")\n\t\t} else {\n\t\t\t// Explicit cancellation stops the run itself, not just its pending items.\n\t\t\tsetErr = b.SetRunFailure(session.RunFailureCancelled, \"review was cancelled\")\n\t\t}\n\t\tif setErr != nil {\n\t\t\ta.recordWarning(\"manifest_error\", \"\", setErr.Error())\n\t\t}","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/agent/agent.go#L801-L837","documentation":"dispatchSubtasks counts dispatched file-review subtasks and their failures. When every dispatched review failed and no comments were reused or collected, the agent returns this error instead of an empty result. It is a client-side summary: the underlying per-file errors (LLM API failures) are recorded per task, and this top-level error tells you the LLM pipeline produced nothing usable.","triggerScenarios":"Agent.Run() where all dispatched per-file review subtasks returned errors (LLMClient failures: auth, network, rate limit, timeout) and CommentCollector has zero comments and no reused items.","commonSituations":"Expired or wrong API key, missing model name, wrong provider endpoint, corporate proxy blocking the API, quota exhausted, request context cancelled before any file completed.","solutions":["Check the per-file errors in the session/manifest output to see the actual LLM failure cause.","Verify the LLM API key, provider, endpoint and model configuration (env vars/config file).","Test connectivity: `curl` the provider endpoint or run a single-file review to isolate network issues.","Check quota/rate limits on the provider dashboard and retry after resolving; resume the session to avoid re-reviewing completed files."],"exampleFix":"// before\nexport OPENAI_API_KEY=sk-old-expired\nocr review\n// -> all 5 file review(s) failed — check your LLM configuration and API key\n// after\nexport OPENAI_API_KEY=sk-valid-current-key\nocr review --resume","handlingStrategy":"fallback","validationCode":"// pre-flight: verify LLM config before dispatching\nif os.Getenv(\"LLM_API_KEY\") == \"\" { return fmt.Errorf(\"missing LLM_API_KEY\") }\n// optional: ping the endpoint with a tiny completion first","typeGuard":null,"tryCatchPattern":"comments, err := agent.Run(ctx)\nif err != nil && strings.Contains(err.Error(), \"file review(s) failed\") {\n    // inspect per-file errors in the session/manifest, fix config, then resume\n    return fmt.Errorf(\"review aborted: %w (resume with --resume to skip completed files)\", err)\n}","preventionTips":["Store and rotate API keys properly; test them with a minimal request before bulk runs.","Set explicit model/provider config and validate it in CI before review jobs.","Watch provider quota/rate limits; add backoff or reduce file concurrency.","Keep the per-file error details from the session output — this summary error hides the root cause by design."],"tags":["llm","api-key","configuration","network"],"backgroundTag":"llm-auth-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}