iflytek/astron-agent · error · AppAuthFailedExc

response code is

Error message

response code is {response.status}

What it means

AppAuthFailedExc raised in app_detail when the auth service responds with a status other than 200. Note the literal string 'response code is {response.status}' is missing the f-prefix, so the actual status code is not interpolated — the developer always sees the placeholder text.

Solutions

  1. Fix the missing f-prefix in the raise so the real status is logged: f"response code is {response.status}"
  2. Check the auth service URL and credentials in configuration
  3. Verify the app_id exists and is accessible from this space
  4. Check auth service health/logs for the non-200 response cause

Example fix

# before
raise AppAuthFailedExc("response code is {response.status}")

# after
raise AppAuthFailedExc(f"response code is {response.status}")
Defensive patterns

Strategy: try-catch

Validate before calling

r = requests.get(auth_url, timeout=10)
if r.status_code != 200:
    logger.warning("app detail returned %s", r.status_code)

Try / catch

try:
    detail = await auth.app_detail(app_id)
except AppAuthFailedExc as e:
    logger.error("app auth failed: %s", e)
    return None

Prevention

When it happens

Trigger: Calling the app-auth detail lookup when the remote auth service returns 4xx/5xx (after raise_for_status passes or for non-200 success-range codes), e.g. app not found, auth service error, or wrong app_id.

Common situations: Misconfigured auth service URL; invalid/expired service credentials; auth service outage returning 500; querying a deleted or wrong-space app_id.

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/e1d9f3984cb93ed7. Report an issue: GitHub.

Appendix: source

Thrown at core/agent/infra/app_auth.py:161

        }
        return headers

    async def app_detail(self, app_id: str) -> Optional[Dict[str, Any]]:
        headers = self.init_header("")
        async with aiohttp.ClientSession() as session:
            timeout = aiohttp.ClientTimeout(total=3)
            async with session.get(
                self.config.url,
                params={"app_ids": app_id + ","},
                headers=headers,
                timeout=timeout,
            ) as response:
                response.raise_for_status()
                if response.status == 200:
                    result = await response.json()
                    return dict(result)

                raise AppAuthFailedExc("response code is {response.status}")


class MaasAuth(BaseModel):
    app_id: str
    model_name: str

    app_id_not_found_msg: str = Field(
        default="Cannot find appid authentication information"
    )

    async def sk(self, span: Span) -> str:
        with span.start("QueryAppIdSk") as sp:
            app_detail = await APPAuth().app_detail(self.app_id)

            sp.add_info_events(
                {
                    "kong-app-detail": json.dumps(
                        {

View on GitHub (pinned to 5e758547a8)