iflytek/astron-agent · critical · ThirdPartyException

CBG_RAGError

CBG_RAGError

Error message

CBG Network error: {e}

What it means

In the traced branch of async_request(), aiohttp.ClientError (connection failures, DNS errors, TLS problems, aborted connections) is caught, logged, recorded on the tracing span, and re-raised as ThirdPartyException with code CBG_RAGError and message 'CBG Network error: ...'. It means the HTTP request to the Xinghuo RAG service failed at the transport level.

Solutions

  1. Test connectivity from the runtime host: curl -v <XINGHUO_RAG_URL> — fix DNS/proxy/firewall accordingly.
  2. Verify XINGHUO_RAG_URL scheme/host/port are correct (https vs http, correct region).
  3. If behind a corporate proxy, set HTTP(S)_PROXY env vars or configure aiohttp trust_env.
  4. Retry the operation; add callers' own backoff around split/get_chunks for transient network faults.

Example fix

# before
resp = await async_request(body, os.getenv("XINGHUO_RAG_URL", "") + "openapi/v1/file/split")
# after
base = os.getenv("XINGHUO_RAG_URL")
if not base:
    raise RuntimeError("XINGHUO_RAG_URL not set")
try:
    resp = await async_request(body, base + "openapi/v1/file/split")
except ThirdPartyException:
    logger.exception("Xinghuo RAG unreachable at %s", base)
    raise
Defensive patterns

Strategy: retry

Validate before calling

import socket
socket.gethostbyname(host_from_url)  # fail fast on DNS problems
# or: curl -sf <XINGHUO_RAG_URL>/health from the deploy script

Type guard

def is_network_error(exc: BaseException) -> bool:
    return isinstance(exc, ThirdPartyException) and "CBG Network error" in str(exc)

Try / catch

for attempt in range(3):
    try:
        return await split(document)
    except ThirdPartyException as e:
        if "CBG Network error" not in str(e) or attempt == 2:
            raise
        await asyncio.sleep(2 ** attempt)

Prevention

When it happens

Trigger: Any async_request-based call (split, get_chunks, new_topk_search, dataset_addchunk, dataset_updchunk) where the TCP connection cannot be established or breaks: host unreachable, DNS failure, TLS handshake error, proxy rejection, connection reset mid-response.

Common situations: XINGHUO_RAG_URL pointing at a wrong host/port; cluster egress firewall blocking the RAG endpoint; VPN or proxy not configured; DNS misconfiguration in containers; Xinghuo service temporarily down.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/99946c3b597ab4a3. Report an issue: GitHub.

Appendix: source

Thrown at core/knowledge/infra/xinghuo/xinghuo.py:445

                        timeout=aiohttp.ClientTimeout(
                            total=float(os.getenv("XINGHUO_CLIENT_TIMEOUT", "60.0"))
                        ),
                    ) as response:
                        background_json = await response.text()
                        span_context.add_info_events({"RAG_OUTPUT": background_json})
                        msg_js = json.loads(background_json)

                        if msg_js["code"] == 0 and msg_js["flag"]:
                            return msg_js["data"]
                        logger.error(
                            url + "Failed to 【XINGHUO-RAG】,err reason %s",
                            msg_js["desc"],
                        )
                        raise ThirdPartyException(msg_js["desc"])
            except aiohttp.ClientError as e:
                logger.error(f"Network error: {e}")
                span_context.record_exception(e)
                raise ThirdPartyException(
                    e=CodeEnum.CBG_RAGError, msg=f"CBG Network error: {e}"
                ) from e
            except asyncio.TimeoutError as e:
                logger.error(f"Request timeout: {url}")
                span_context.record_exception(e)
                raise ThirdPartyException(
                    e=CodeEnum.CBG_RAGError, msg=f"CBG Request timeout: {url}"
                ) from e
    else:
        # Fallback without span
        headers = await assemble_spark_auth_headers_async()
        headers["Content-Type"] = "application/json"

        try:
            async with aiohttp.ClientSession() as session:
                async with session.request(
                    method=method,
                    url=url,

View on GitHub (pinned to 5e758547a8)