iflytek/astron-agent · error · aiohttp.ClientResponseError
HTTP Error
Error message
HTTP Error: {text} What it means
The iFlytek audit API client's _do_request raises aiohttp.ClientResponseError whenever the audit service responds with a status other than 200. The response body is placed in the error message, and _request_with_retry propagates it upward. Any non-200 (auth failure, bad payload, server error) aborts the audit submission.
Solutions
- Inspect the raised message text and any retry logs to see the exact status/body from the audit service
- Verify audit API credentials, URL, and timeout configuration
- Replay the failing payload against the audit endpoint with curl to confirm whether it is client- or server-side
- Ensure _request_with_retry retries only transient statuses (429/5xx) and surfaces 4xx as config errors
Example fix
// before
if response.status != 200:
text = await response.text()
raise aiohttp.ClientResponseError(..., message=f"HTTP Error: {text}")
// after
if response.status != 200:
text = await response.text()
logger.error("ifly audit api %s -> %s: %s", url, response.status, text)
raise aiohttp.ClientResponseError(..., message=f"Audit API returned {response.status}: {text}") Defensive patterns
Strategy: try-catch
Validate before calling
async def audit_api_reachable(url, payload_headers):
try:
async with HttpClient.get_session().get(url, timeout=5) as r:
return r.status in (200, 204)
except aiohttp.ClientError:
return False Try / catch
try:
await audit_client._request_with_retry(payload)
except aiohttp.ClientResponseError as e:
if e.status >= 500 or e.status == 429:
schedule_retry(e)
else:
logger.error("audit api config error: %s %s", e.status, e.message)
raise Prevention
- Verify audit service URL/credentials in config after each deployment
- Retry only transient statuses; treat 4xx as configuration bugs
- Monitor audit endpoint latency and error rates
When it happens
Trigger: _request_with_retry calls _do_request, which posts the audit payload via HttpClient.get_session().post(url, json=payload, timeout=timeout); the audit endpoint returns status != 200, so the body text is raised in a ClientResponseError.
Common situations: Expired audit-service API credentials, audit endpoint URL changed after service upgrade, payload exceeding audit service limits (400), audit service overloaded (500/503), or network gateway intercepting with 404/502.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/b0629d6fd2b7a509.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py:206
async def _do_request(self, url: str, payload: dict) -> dict:
"""
Do request to audit API.
:param url: Request URL
:param payload: Request payload
:return: Response result dictionary containing audit results
:raises aiohttp.ClientResponseError: If request fails with non-retryable error
"""
timeout = aiohttp.ClientTimeout(
sock_connect=CONNECT_TIMEOUT, sock_read=TEXT_READ_TIMEOUT
)
async with HttpClient.get_session().post(
url, json=payload, timeout=timeout
) as response:
if response.status != 200:
text = await response.text()
raise aiohttp.ClientResponseError(
request_info=response.request_info,
history=response.history,
status=response.status,
message=f"HTTP Error: {text}",
)
return await response.json()
@retry(
stop=stop_after_attempt(RETRY_COUNT), # Maximum number of retry attempts
wait=wait_fixed(1), # Wait time between retries
retry=retry_if_exception_type(
(
aiohttp.ClientError,
asyncio.TimeoutError,
NeedRetryException,
) # Retry on these exceptions
),
reraise=True, # Reraise the exception if all retry attempts failView on GitHub (pinned to 5e758547a8)