{"record":{"id":"1103aef091c53505","repo":"iflytek/astron-agent","slug":"dynamic-request-failure-str-err","errorCode":null,"errorMessage":"<dynamic request failure: str(err)>","messagePattern":"<dynamic request failure: str\\(err\\)>","errorType":"error_code","errorClass":"CallThirdApiException","httpStatus":null,"severity":"error","filePath":"core/plugin/link/infra/tool_exector/process.py","lineNumber":265,"sourceCode":"\n        with span.start(func_name=\"http_run\") as span_context:\n            try:\n                third_result, status_code = await self._execute_request(\n                    url, span_context\n                )\n            except CallThirdApiException:\n                raise\n            except OutboundPolicyError as err:\n                span.add_error_event(str(err))\n                raise CallThirdApiException(\n                    code=ErrCode.SERVER_VALIDATE_ERR.code,\n                    err_pre=ErrCode.SERVER_VALIDATE_ERR.msg,\n                    err=str(err),\n                ) from err\n            except Exception as err:\n                span.add_error_event(str(err))\n                code_return, err_pre_return = self._get_error_codes()\n                raise CallThirdApiException(\n                    code=code_return, err_pre=err_pre_return, err=str(err)\n                ) from err\n\n        if status_code != 200:\n            err_reason = (\n                f\"Request error code: {status_code}, error message {third_result}\"\n            )\n            code_return, err_pre_return = self._get_error_codes()\n            raise CallThirdApiException(\n                code=code_return, err_pre=err_pre_return, err=err_reason\n            )\n\n        return third_result\n\n    @staticmethod\n    def is_authorization_md5(open_api_schema: Optional[Dict[str, Any]]) -> bool:\n        \"\"\"Check if the API uses MD5 authorization.\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/infra/tool_exector/process.py#L247-L283","documentation":"Any non-policy exception during request execution (aiohttp connection errors, timeouts, TLS failures, unexpected client errors) is caught by do_call's generic handler, recorded on the tracing span, and re-raised as CallThirdApiException using the error code/prefix appropriate for the API type (OFFICIAL_API_REQUEST_FAILED_ERR or THIRD_API_REQUEST_FAILED_ERR) with the original exception text in err.","triggerScenarios":"do_call → _execute_request raises e.g. aiohttp.ClientConnectorError (connection refused/DNS failure), ServerTimeoutError, ClientSSLError, or any other unexpected exception while performing the aiohttp request.","commonSituations":"Third-party API host down or unreachable from the cluster; egress firewall dropping the connection; wrong port; TLS certificate problems; network partition between link service and provider.","solutions":["Read err for the underlying exception message (e.g. 'Cannot connect to host ... Connection refused') and fix the network/endpoint cause","Verify the tool endpoint host/port/DNS from inside the deployment (curl/ping from the same network)","Add retry with backoff in the caller for transient network faults, or correct TLS/proxy configuration"],"exampleFix":"// before\ncode, prefix = ErrCode.THIRD_API_REQUEST_FAILED_ERR.code, ErrCode.THIRD_API_REQUEST_FAILED_ERR.msg\n// after (caller-side retry for transient faults)\nfor attempt in range(3):\n    try:\n        return await run.do_call(span)\n    except CallThirdApiException:\n        if attempt == 2: raise\n        await asyncio.sleep(2 ** attempt)","handlingStrategy":"retry","validationCode":"import asyncio\nasync def with_retry(call, retries=3):\n    for i in range(retries):\n        try:\n            return await call()\n        except CallThirdApiException as e:\n            if 'Cannot connect' not in str(e.err) or i == retries - 1:\n                raise\n            await asyncio.sleep(2 ** i)","typeGuard":null,"tryCatchPattern":"try:\n    result = await run.do_call(span)\nexcept CallThirdApiException as e:\n    if 'Cannot connect' in str(e.err) or 'Timeout' in str(e.err):\n        raise TransientNetworkError(e.err) from e\n    raise","preventionTips":["Add retry with exponential backoff for transient faults","Verify egress firewall rules allow the provider's host/port","Health-check third-party endpoints before registering tools"],"tags":["network","http","aiohttp"],"backgroundTag":"network-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"}