{"record":{"id":"076c3038b1a82868","repo":"ZhuLinsen/daily_stock_analysis","slug":"unknown-backend-error","errorCode":"unknown_backend_error","errorMessage":"fallback_backend_failed","messagePattern":"fallback_backend_failed","errorType":"error_code","errorClass":"GenerationError","httpStatus":null,"severity":"critical","filePath":"src/analyzer.py","lineNumber":3062,"sourceCode":"                        \"reason\": \"fallback_backend_failed\",\n                        \"primary_error\": {\n                            \"error_code\": exc.error_code.value,\n                            \"backend\": exc.backend,\n                            \"provider\": exc.provider,\n                            \"stage\": exc.stage,\n                            \"details\": exc.details,\n                        },\n                        \"fallback_error\": {\n                            \"error_code\": fallback_exc.error_code.value,\n                            \"backend\": fallback_exc.backend,\n                            \"provider\": fallback_exc.provider,\n                            \"stage\": fallback_exc.stage,\n                            \"details\": fallback_exc.details,\n                        },\n                    },\n                ) from fallback_exc\n            except Exception as fallback_exc:\n                raise GenerationError(\n                    error_code=GenerationErrorCode.UNKNOWN_BACKEND_ERROR,\n                    stage=\"fallback\",\n                    retryable=False,\n                    fallbackable=False,\n                    backend=fallback_backend_id,\n                    provider=fallback_backend_id,\n                    details={\n                        \"reason\": \"fallback_backend_failed\",\n                        \"primary_error\": {\n                            \"error_code\": exc.error_code.value,\n                            \"backend\": exc.backend,\n                            \"provider\": exc.provider,\n                            \"stage\": exc.stage,\n                            \"details\": exc.details,\n                        },\n                        \"fallback_error\": str(fallback_exc),\n                    },\n                ) from fallback_exc","sourceCodeStart":3044,"sourceCodeEnd":3080,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/analyzer.py#L3044-L3080","documentation":"GenerationError with code UNKNOWN_BACKEND_ERROR raised at stage 'fallback' when the primary backend already raised a GenerationError (exc) and the subsequent fallback backend attempt failed with an unexpected non-GenerationError exception (fallback_exc). The 'reason' detail is 'fallback_backend_failed'; the error preserves both the primary error and the raw fallback exception in details for diagnosis. retryable and fallbackable are both False because the chain is exhausted.","triggerScenarios":"Generation with a primary + fallback backend configured (e.g. litellm primary, another provider fallback) where the primary fails with a structured GenerationError AND the fallback attempt throws an arbitrary exception (network TypeError, missing dependency, bad config) that is not itself a GenerationError.","commonSituations":"Fallback provider env vars not configured (key missing -> AttributeError/KeyError in its client); a version change in the fallback SDK raising a new exception type; transient network outage hitting both backends where the fallback fails before producing a structured error.","solutions":["Inspect details['fallback_error'] / the chained exception to identify what the fallback backend actually threw and fix that root cause first.","Verify the fallback backend's credentials, model list, and dependencies are complete — partial fallback config is the most common cause.","If the primary error (details['primary_error']) is itself retryable, fix or retry the primary path rather than relying on the broken fallback.","As a last resort, add another healthy fallback backend or disable the broken one so the chain degrades cleanly."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from src.analyzer import GenerationError\n\ntry:\n    result = run_generation(...)\nexcept GenerationError as e:\n    if e.details.get(\"reason\") == \"fallback_backend_failed\":\n        log_primary = e.details[\"primary_error\"]\n        log_fallback = e.details.get(\"fallback_exc\")\n        # both backends broken: do not retry blindly; alert ops / degrade to cached report\n    raise","preventionTips":["Health-check every configured backend at startup, not just the primary.","Keep fallback backend credentials and deps fully configured — partial fallback config is the top cause.","Preserve and log details['primary_error'] to avoid fixing the wrong backend."],"tags":["llm","generation","fallback","error-chaining"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}