Description
When calling Files::retrieve($fileId) via the PHP SDK, intermittent 503 responses from the API edge (HTML “503 Service Temporarily Unavailable” from OpenAI's nginx) cause the transporter to attempt json_decode() on the HTML body. This triggers:
OpenAI\Exceptions\UnserializableResponse
Syntax error
vendor/openai-php/client/src/Transporters/HttpTransporter.php:62
Because the response isn’t JSON, the SDK error is misleading and hides the actual HTTP status/body. This makes handling/retrying 5xx conditions difficult.
Steps To Reproduce
-
Environment (example):
- PHP: 8.x
- SDK:
openai-php/client (latest at time of issue)
-
Code (minimal):
$fileId = 'file_XXXXXXXXXXXX';
// Repro: call retrieve on an existing file id
$file = $client->files()->retrieve($fileId);
-
Intermittently, the API responds with a 503 HTML page (edge/nginx). If you dump the raw contents in the transporter you’ll see something like:
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
-
The SDK attempts to json_decode() this HTML and throws:
OpenAI\Exceptions\UnserializableResponse (Syntax error)
at vendor/openai-php/client/src/Transporters/HttpTransporter.php:62
OpenAI PHP Client Version
v0.16.0
PHP Version
8.4.6
Notes
Description
When calling
Files::retrieve($fileId)via the PHP SDK, intermittent 503 responses from the API edge (HTML “503 Service Temporarily Unavailable” from OpenAI's nginx) cause the transporter to attemptjson_decode()on the HTML body. This triggers:Because the response isn’t JSON, the SDK error is misleading and hides the actual HTTP status/body. This makes handling/retrying 5xx conditions difficult.
Steps To Reproduce
Environment (example):
openai-php/client(latest at time of issue)Code (minimal):
Intermittently, the API responds with a 503 HTML page (edge/nginx). If you dump the raw contents in the transporter you’ll see something like:
The SDK attempts to
json_decode()this HTML and throws:OpenAI PHP Client Version
v0.16.0
PHP Version
8.4.6
Notes
The error originates here:
vendor/openai-php/client/src/Transporters/HttpTransporter.php:62