iflytek/astron-agent · error · ThirdPartyException

DESK_RAGError

DESK_RAGError

Error message

SPARKDESK-RAG request failed with status: {resp.status}

What it means

async_request in core/knowledge/infra/desk/sparkdesk.py checks the HTTP response status of the SPARKDESK-RAG endpoint; if resp.status != 200 it logs and raises ThirdPartyException(DESK_RAGError) with f"SPARKDESK-RAG request failed with status: {resp.status}". It surfaces the raw status because the body was not yet parsed as JSON.

Solutions

  1. Read the status code in the message: 401/403 → fix SPARKDESK credentials; 404 → fix desk_url; 429 → back off and retry; 5xx → check SPARKDESK service health.
  2. Verify the configured SPARKDESK-RAG URL and auth environment variables.
  3. Confirm the SPARKDESK-RAG service is running and reachable from the knowledge service (network/ingress checks).
  4. Add retry-with-backoff for 429/5xx statuses before surfacing the error to users.

Example fix

// before
resp = await session.post(desk_url, json=payload)
// after (defensive caller)
try:
    data = await sparkdesk_query_async(payload)
except ThirdPartyException as e:
    if "status: 429" in str(e) or "status: 5" in str(e):
        await asyncio.sleep(2)
        data = await sparkdesk_query_async(payload)
    else:
        raise
Defensive patterns

Strategy: try-catch

Validate before calling

assert os.getenv("SPARKDESK_URL"), "SPARKDESK_URL not configured"

Type guard

null

Try / catch

try:
    data = await sparkdesk_query_async(payload)
except ThirdPartyException as e:
    if "status: 429" in str(e) or "status: 5" in str(e):
        await asyncio.sleep(2)  # retry transient statuses
    else:
        raise

Prevention

When it happens

Trigger: Calling sparkdesk_query_async when the SPARKDESK-RAG service returns any non-200 HTTP status: 401/403 from bad credentials, 404 from a wrong desk_url path, 429 rate limiting, or 5xx from the SparkDesk backend.

Common situations: Wrong SPARKDESK base URL or app id/password in env; expired SparkDesk credentials; gateway (nginx/istio) returning 502/504 when the backend is down; sending to the wrong API version path.

Related errors


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

Appendix: source

Thrown at core/knowledge/infra/desk/sparkdesk.py:102

                        json=body,
                        headers=await assemble_auth_headers_async(),
                        timeout=aiohttp.ClientTimeout(
                            total=float(os.getenv("DESK_CLIENT_TIMEOUT", "30"))
                        ),  # Set timeout
                    ) as resp:

                        response_text = await resp.text()
                        logger.info(
                            f"Async response from SPARKDESK-RAG: {response_text}"
                        )
                        span_context.add_info_events(
                            {"SPARKDESK_OUTPUT": response_text}
                        )

                        if resp.status != 200:
                            error_msg = f"SPARKDESK-RAG request failed with status: {resp.status}"
                            logger.error(error_msg)
                            raise ThirdPartyException(
                                e=CodeEnum.DESK_RAGError, msg=error_msg
                            )

                        try:
                            msg_js = json.loads(response_text)
                        except json.JSONDecodeError as e:
                            error_msg = f"Failed to parse JSON response: {e}"
                            logger.error(error_msg)
                            raise ThirdPartyException(
                                e=CodeEnum.DESK_RAGError, msg=error_msg
                            ) from e

                        if msg_js.get("code") == 0 and msg_js.get("flag"):
                            return msg_js.get("data", {})
                        error_desc = msg_js.get(
                            "desc", "Unknown error from SPARKDESK-RAG"
                        )
                        logger.error(f"SPARKDESK-RAG API error: {error_desc}")

View on GitHub (pinned to 5e758547a8)