{"record":{"id":"7fc58a964dcd4038","repo":"iflytek/astron-agent","slug":"9010-invoke-oss-error-status-code-resp-status-code-message","errorCode":"9010","errorMessage":"invoke oss error, status_code: {resp.status_code}, message: {resp.text}","messagePattern":"invoke oss error, status_code: (.+?), message: (.+?)","errorType":"error_code","errorClass":"OssServiceException","httpStatus":null,"severity":"error","filePath":"core/common/service/oss/ifly_storage_gateway_service.py","lineNumber":69,"sourceCode":"            \"filename\": filename,\n            \"expose\": \"true\",\n        }\n        url = url + \"?\" + urlencode(params)\n        headers = HMACAuth.build_auth_header(\n            url,\n            method=\"POST\",\n            api_key=self.access_key_id,\n            api_secret=self.access_key_secret,\n        )\n        headers[\"X-TTL\"] = str(self.ttl)\n        headers[\"Content-Length\"] = str(len(file_bytes))\n        try:\n            resp = requests.post(url, headers=headers, data=file_bytes)\n        except Exception as e:\n            logger.error(e)\n            return \"\"\n        if resp.status_code != 200:\n            raise OssServiceException(*c9010)(\n                f\"invoke oss error, status_code: {resp.status_code}, message: {resp.text}\"\n            )\n\n        ret = resp.json()\n        if ret[\"code\"] != 0:\n            raise OssServiceException(*c9010)(\n                f\"invoke oss error, status_code: {resp.status_code}, message: {resp.text}\"\n            )\n        try:\n            link = ret[\"data\"][\"link\"]\n        except Exception:\n            raise OssServiceException(*c9010)(\n                f\"invoke oss error, status_code: {resp.status_code}, message: {resp.text}\"\n            )\n        return link\n","sourceCodeStart":51,"sourceCodeEnd":85,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/common/service/oss/ifly_storage_gateway_service.py#L51-L85","documentation":"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.","triggerScenarios":"`requests.post(url, headers=headers, data=file_bytes)` to the storage gateway returns `resp.status_code != 200` in `upload_file`.","commonSituations":"Storage gateway down or overloaded (5xx); auth headers missing/expired (401); object-size or policy rejection (413/400); wrong gateway URL configured.","solutions":["Check the embedded status_code/message to identify auth vs server vs request problems.","Verify the OSS gateway URL and upload auth headers/credentials are current.","Confirm the gateway service is healthy and reachable from the caller.","Add a retry with backoff for transient 5xx before surfacing the exception."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"def validate_upload(file_bytes: bytes, gateway_url: str) -> None:\n    if not file_bytes:\n        raise ValueError(\"empty file\")\n    if not gateway_url.startswith((\"http://\", \"https://\")):\n        raise ValueError(\"invalid OSS gateway URL\")","typeGuard":null,"tryCatchPattern":"try:\n    link = await oss_service.upload_file(...)\nexcept OssServiceException as e:\n    logger.error(\"oss upload failed: %s\", e)  # includes status_code and body\n    raise","preventionTips":["Retry transient 5xx uploads with exponential backoff.","Verify gateway auth headers are refreshed before expiry.","Check gateway health before large batch uploads.","Enforce client-side size limits to avoid 413 rejections."],"tags":["oss","http","upload","storage"],"backgroundTag":"http-error-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}