iflytek/astron-agent · error · OssServiceException

9010

9010

Error message

invoke oss error, status_code: {resp.status_code}, message: {resp.text}

What it means

The iFlytek storage gateway (OSS) client raises `OssServiceException(*c9010)` in `upload_file` when the HTTP upload POST returns a non-200 status; the message embeds the status code and response body.

Solutions

  1. Check the embedded status_code/message to identify auth vs server vs request problems.
  2. Verify the OSS gateway URL and upload auth headers/credentials are current.
  3. Confirm the gateway service is healthy and reachable from the caller.
  4. Add a retry with backoff for transient 5xx before surfacing the exception.
Defensive patterns

Strategy: retry

Validate before calling

def validate_upload(file_bytes: bytes, gateway_url: str) -> None:
    if not file_bytes:
        raise ValueError("empty file")
    if not gateway_url.startswith(("http://", "https://")):
        raise ValueError("invalid OSS gateway URL")

Try / catch

try:
    link = await oss_service.upload_file(...)
except OssServiceException as e:
    logger.error("oss upload failed: %s", e)  # includes status_code and body
    raise

Prevention

When it happens

Trigger: `requests.post(url, headers=headers, data=file_bytes)` to the storage gateway returns `resp.status_code != 200` in `upload_file`.

Common situations: Storage gateway down or overloaded (5xx); auth headers missing/expired (401); object-size or policy rejection (413/400); wrong gateway URL configured.

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

Appendix: source

Thrown at core/common/service/oss/ifly_storage_gateway_service.py:69

            "filename": filename,
            "expose": "true",
        }
        url = url + "?" + urlencode(params)
        headers = HMACAuth.build_auth_header(
            url,
            method="POST",
            api_key=self.access_key_id,
            api_secret=self.access_key_secret,
        )
        headers["X-TTL"] = str(self.ttl)
        headers["Content-Length"] = str(len(file_bytes))
        try:
            resp = requests.post(url, headers=headers, data=file_bytes)
        except Exception as e:
            logger.error(e)
            return ""
        if resp.status_code != 200:
            raise OssServiceException(*c9010)(
                f"invoke oss error, status_code: {resp.status_code}, message: {resp.text}"
            )

        ret = resp.json()
        if ret["code"] != 0:
            raise OssServiceException(*c9010)(
                f"invoke oss error, status_code: {resp.status_code}, message: {resp.text}"
            )
        try:
            link = ret["data"]["link"]
        except Exception:
            raise OssServiceException(*c9010)(
                f"invoke oss error, status_code: {resp.status_code}, message: {resp.text}"
            )
        return link

View on GitHub (pinned to 5e758547a8)