iflytek/astron-agent · error · CustomException

CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR

CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR

Error message

appid is null

What it means

_get_app_source_detail_with_api_key calls a remote app service and expects resp.json()['data']['appid']. If the remote response succeeds but contains no appid, it raises CustomException CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR 'appid is null' with the raw response body as cause_error.

Solutions

  1. Verify the API key/secret correspond to a live app on the remote service
  2. Inspect cause_error (the remote response body) to see what the remote actually returned
  3. Check the remote service's response schema for version changes to the 'data.appid' path
  4. Add retry/fallback handling if the upstream intermittently returns empty data

Example fix

# before
app_id = resp.json().get("data", {}).get("appid")
# after
app_id = resp.json().get("data", {}).get("appid")
if not app_id:
    logger.warning(f"remote app lookup returned no appid: {resp.text}")  # diagnose via cause_error
    raise ...
Defensive patterns

Strategy: try-catch

Validate before calling

resp_json = resp.json()
assert resp_json.get("data", {}).get("appid"), "remote app lookup returned no appid; verify the app/key exists"

Try / catch

try:
    detail = await middleware._get_app_source_detail_with_api_key(request)
except CustomException as e:
    if e.err_code == CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR:
        logger.error(f"remote app lookup failed: {e.cause_error}")
        raise HTTPException(status_code=401, detail="unknown or revoked app credentials")
    raise

Prevention

When it happens

Trigger: The remote app-detail API returns 200 but data is empty, data.appid is absent, or the app record exists without an appid field — typically the API key is valid syntactically but does not map to a real app.

Common situations: Revoked or deleted app whose API key still passes format checks; upstream service degraded and returning an error body with 200; response envelope changed (data nested differently) after an API version change.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at core/workflow/extensions/fastapi/middleware/auth.py:322

                "message": "success",
                "data": {
                    "appid": "007d72a3",
                    "name": "11212311313131",
                    "source": "78263c167bab",
                    "desc": "12121"
                }
            }
        """
        code = resp.json().get("code")
        if code != 0:
            raise CustomException(
                CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR,
                cause_error=json.dumps(resp.json(), ensure_ascii=False),
            )

        app_id = resp.json().get("data", {}).get("appid")
        if not app_id:
            raise CustomException(
                CodeEnum.APP_GET_WITH_REMOTE_FAILED_ERROR,
                err_msg="appid is null",
                cause_error=json.dumps(resp.json(), ensure_ascii=False),
            )
        await asyncio.to_thread(
            self._set_app_id_with_cache, credential_cache_digest, app_id
        )
        return app_id

    def _get_app_id_with_cache(self, credential_cache_key: str) -> str:
        """
        Get the app id with cache

        :param credential_cache_key: PBKDF2-HMAC digest of the complete credential pair
        :return: The app id
        """
        cache_service = get_cache_service()
        app_id: str = cache_service[

View on GitHub (pinned to 5e758547a8)