{"record":{"id":"965a9e3f862e0b77","repo":"iflytek/astron-agent","slug":"desc-from-xinghuo-rag-response","errorCode":null,"errorMessage":"{desc from XINGHUO-RAG response}","messagePattern":"\\{desc from XINGHUO-RAG response\\}","errorType":"exception","errorClass":"ThirdPartyException","httpStatus":null,"severity":"error","filePath":"core/knowledge/infra/xinghuo/xinghuo.py","lineNumber":441,"sourceCode":"                        method=method,\n                        url=url,\n                        data=json.dumps(body),\n                        headers=headers,\n                        timeout=aiohttp.ClientTimeout(\n                            total=float(os.getenv(\"XINGHUO_CLIENT_TIMEOUT\", \"60.0\"))\n                        ),\n                    ) as response:\n                        background_json = await response.text()\n                        span_context.add_info_events({\"RAG_OUTPUT\": background_json})\n                        msg_js = json.loads(background_json)\n\n                        if msg_js[\"code\"] == 0 and msg_js[\"flag\"]:\n                            return msg_js[\"data\"]\n                        logger.error(\n                            url + \"Failed to 【XINGHUO-RAG】,err reason %s\",\n                            msg_js[\"desc\"],\n                        )\n                        raise ThirdPartyException(msg_js[\"desc\"])\n            except aiohttp.ClientError as e:\n                logger.error(f\"Network error: {e}\")\n                span_context.record_exception(e)\n                raise ThirdPartyException(\n                    e=CodeEnum.CBG_RAGError, msg=f\"CBG Network error: {e}\"\n                ) from e\n            except asyncio.TimeoutError as e:\n                logger.error(f\"Request timeout: {url}\")\n                span_context.record_exception(e)\n                raise ThirdPartyException(\n                    e=CodeEnum.CBG_RAGError, msg=f\"CBG Request timeout: {url}\"\n                ) from e\n    else:\n        # Fallback without span\n        headers = await assemble_spark_auth_headers_async()\n        headers[\"Content-Type\"] = \"application/json\"\n\n        try:","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/infra/xinghuo/xinghuo.py#L423-L459","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the `desc` in the message — it names the server-side reason; fix the request accordingly.","Validate auth env vars/headers (assemble_spark_auth_headers_async) if desc suggests authentication failure.","Confirm the file_id/doc_id/dataset ids exist in the Xinghuo console before calling.","Compare your request body against the Xinghuo RAG API docs for the specific endpoint."],"exampleFix":"# before\nresp = await async_request(body, url)  # desc: 'invalid appId'\n# after\nassert os.getenv(\"XINGHUO_APP_ID\") and os.getenv(\"XINGHUO_APP_SECRET\"), \"Xinghuo credentials missing\"\nresp = await async_request(body, url)","handlingStrategy":"try-catch","validationCode":"assert os.getenv(\"XINGHUO_APP_ID\"), \"Xinghuo appId missing\"\nassert os.getenv(\"XINGHUO_APP_SECRET\"), \"Xinghuo appSecret missing\"\n# and validate referenced ids exist before calling","typeGuard":"def api_ok(payload: object) -> bool:\n    return isinstance(payload, dict) and payload.get(\"code\") == 0 and bool(payload.get(\"flag\"))","tryCatchPattern":"try:\n    data = await async_request(body, url)\nexcept ThirdPartyException as e:\n    logger.error(\"Xinghuo RAG rejected request: %s\", e)  # desc explains cause\n    raise","preventionTips":["Read and act on the `desc` text — it is the server's own diagnosis.","Keep Xinghuo credentials in env/secret manager and rotate before expiry.","Verify ids (file/doc/dataset/chunk) exist remotely before referencing them."],"tags":["third-party","api-error","rag","http"],"backgroundTag":"api-error-response","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"}