iflytek/astron-agent · error · ThirdPartyException

{desc from XINGHUO-RAG response}

Error message

{desc from XINGHUO-RAG response}

What it means

async_request() (the instrumented/traced branch) parses the Xinghuo RAG JSON response and, when msg_js["code"] != 0 or flag is falsy, raises ThirdPartyException whose message is the server-provided `desc`. This is the Xinghuo API explicitly reporting a business-level failure (auth, bad request, missing resource, quota, etc.) for endpoints like split, chunks, topk search, and dataset chunk add/update.

Solutions

  1. Read the `desc` in the message — it names the server-side reason; fix the request accordingly.
  2. Validate auth env vars/headers (assemble_spark_auth_headers_async) if desc suggests authentication failure.
  3. Confirm the file_id/doc_id/dataset ids exist in the Xinghuo console before calling.
  4. Compare your request body against the Xinghuo RAG API docs for the specific endpoint.

Example fix

# before
resp = await async_request(body, url)  # desc: 'invalid appId'
# after
assert os.getenv("XINGHUO_APP_ID") and os.getenv("XINGHUO_APP_SECRET"), "Xinghuo credentials missing"
resp = await async_request(body, url)
Defensive patterns

Strategy: try-catch

Validate before calling

assert os.getenv("XINGHUO_APP_ID"), "Xinghuo appId missing"
assert os.getenv("XINGHUO_APP_SECRET"), "Xinghuo appSecret missing"
# and validate referenced ids exist before calling

Type guard

def api_ok(payload: object) -> bool:
    return isinstance(payload, dict) and payload.get("code") == 0 and bool(payload.get("flag"))

Try / catch

try:
    data = await async_request(body, url)
except ThirdPartyException as e:
    logger.error("Xinghuo RAG rejected request: %s", e)  # desc explains cause
    raise

Prevention

When it happens

Trigger: Any async_request call (split, get_chunks, new_topk_search, dataset_addchunk, dataset_updchunk) where the remote API answers HTTP 200 with a JSON body whose code is non-zero or flag is false — e.g. invalid app id/secret in auth headers, unknown file_id or doc_id, malformed request body, expired token.

Common situations: Wrong or expired Xinghuo credentials configured via env vars; referencing a deleted knowledge-base/document id; sending chunk sizes or ids outside allowed limits; copy-pasted endpoints that don't match the deployed API version.

Related errors


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

Appendix: source

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

                        method=method,
                        url=url,
                        data=json.dumps(body),
                        headers=headers,
                        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:

View on GitHub (pinned to 5e758547a8)