{"record":{"id":"13ac6d401f7d2b65","repo":"iflytek/astron-agent","slug":"all-retry-attempts-failed","errorCode":null,"errorMessage":"All retry attempts failed","messagePattern":"All retry attempts failed","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/ragflow/ragflow_client.py","lineNumber":363,"sourceCode":"                raise Exception(f\"API request failed: {status} - {result}\")\n\n            return result\n\n        except (aiohttp.ClientConnectionError, RuntimeError) as e:\n            if _is_session_closed_error(e):\n                await _handle_session_error(attempt, max_retries, e)\n                continue\n            else:\n                raise e\n        except Exception as e:\n            logger.error(f\"Request failed: {method} {endpoint} - {e}\")\n            logger.error(f\"Request URL: {url}\")\n            if data:\n                logger.error(f\"Request data: {data}\")\n            raise\n\n    # This should never be reached due to exceptions being raised\n    raise Exception(\"All retry attempts failed\")\n\n\nasync def cleanup_session() -> None:\n    \"\"\"\n    Clean up session resources (called when application shuts down)\n    \"\"\"\n    global _session_cache\n\n    if _session_cache and not _session_cache.closed:\n        await _session_cache.close()\n        _session_cache = None\n        logger.info(\"RAGFlow HTTP session cleaned up\")\n\n\ndef reload_config() -> None:\n    \"\"\"\n    Reload configuration (called after configuration changes)\n    \"\"\"","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/ragflow/ragflow_client.py#L345-L381","documentation":"Defensive terminal raise at the end of _make_request's retry loop in ragflow_client.py. Because every failed attempt is supposed to raise (final API error, session-retry exhaustion, or the logged-and-re-raised exception), the loop should never fall through; if it does (e.g. a retry path returns None instead of raising), the code raises Exception('All retry attempts failed').","triggerScenarios":"Exhausting max_retries in _make_request without any earlier raise — practically triggered when session-error handling or a future code path returns control without raising, or when the retry loop condition is off-by-one relative to error handling.","commonSituations":"Bug in retry logic after modifying max_retries; partial failures across a RAGFlow server outage where each attempt fails in a way currently swallowed; running with a custom build where an except branch was changed to log-and-continue.","solutions":["Inspect the logs immediately above the raise (Request URL / Request data are logged) to find the per-attempt failure","Fix the swallowing except branch so the genuine error propagates instead of falling through the loop","Increase max_retries only if the failures are transient (server restarts); otherwise fix the root cause","Ensure RAGFlow server availability during the retry window"],"exampleFix":"# before\nexcept Exception as e:\n    logger.error(f\"... {e}\")\n    # falls through, eventually hits 'All retry attempts failed'\n# after\nexcept Exception as e:\n    logger.error(f\"Request failed: {e}\")\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await retrieval_with_dataset(dataset_id, query)\nexcept Exception as e:\n    if str(e) == 'All retry attempts failed':\n        logger.error('RAGFlow exhausted retries; check earlier logs for per-attempt cause')\n        raise","preventionTips":["Never convert a raising except branch into log-and-continue in retry loops","Keep retry loop bounds consistent with the retry-exhaustion checks","Ensure RAGFlow server availability windows cover retry backoff durations"],"tags":["retry","http","ragflow","internal"],"backgroundTag":"api-request-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}