{"record":{"id":"1c31033541fd5efc","repo":"srbhr/Resume-Matcher","slug":"failed-after-retries-1-attempts","errorCode":null,"errorMessage":"Failed after {retries + 1} attempts","messagePattern":"Failed after (.+?) attempts","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"apps/backend/app/llm.py","lineNumber":1360,"sourceCode":"            ):\n                json_mode_failed = True\n                logging.warning(\n                    \"Provider rejected response_format for %s; falling back to \"\n                    \"prompt-only JSON mode (attempt %d)\",\n                    model_name,\n                    attempt + 1,\n                )\n                if attempt < retries:\n                    continue\n            raise\n\n        except Exception:\n            # Transport errors — Router already retried with backoff.\n            # Cooldowns are disabled (see _build_router); no additional\n            # retry is attempted here.\n            raise\n\n    raise ValueError(f\"Failed after {retries + 1} attempts\")\n","sourceCodeStart":1342,"sourceCodeEnd":1361,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/llm.py#L1342-L1361","documentation":"complete_json loops for up to retries + 1 attempts; if the loop exits without returning (all attempts consumed by content-quality failures that didn't raise), it raises this generic ValueError. Transport errors are re-raised as-is since the LiteLLM Router already retried with backoff.","triggerScenarios":"Every attempt of complete_json fails with empty responses or extraction failures, the retry loop is exhausted, and the final raise at the end of the function is reached.","commonSituations":"Sustained provider degradation returning empty/bad content across all retries; retries configured to 0; model systematically unable to satisfy the prompt's JSON requirement.","solutions":["Increase retries in the complete_json call","Check server logs for the per-attempt warnings ('Content extraction failed (attempt N)') to find the root cause","Switch to a stronger model or enable JSON mode for the request","Add a fallback UX (cached result or graceful degradation) in the calling feature (analyze_resume, generate_enhancements, etc.)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async def llm_healthy() -> bool:\n    try:\n        await complete_json('Return {\"ok\": true}', retries=1)\n        return True\n    except ValueError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    data = await complete_json(prompt)\nexcept ValueError:\n    # includes 'Failed after N attempts'\n    return serve_cached_or_default_result()\nexcept Exception:\n    # transport errors — Router already retried; surface as 503\n    raise ServiceUnavailable(\"LLM provider unreachable\")","preventionTips":["Configure a sensible retries value for all complete_json calls","Watch logs for repeated 'Content extraction failed' warnings — a sign of model/prompt mismatch","Design caller features (analyze_resume, generate_enhancements) with fallbacks","Health-check the LLM path at deploy time"],"tags":["llm","retry-exhausted","backend"],"backgroundTag":"retry-limit-exceeded","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}