You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: Exception 'TypeError' with message 'OpenAI\Exceptions\ErrorException::__construct(): Argument #1 ($contents) must be of type array, string given, called in vendor/openai-php/client/src/Transporters/HttpTransporter.php on line 133' #622
When calling OpenAI::models()->list(), an uncaught TypeError is thrown due to ErrorException::__construct() receiving a string instead of the expected array.
The throwIfJsonError() method passes the raw response body (a string) into ErrorException::__construct() expecting it to be an array. However, when the response is invalid JSON or a plain error string (e.g., "PostgresConnectionError"), this causes a fatal TypeError.
Expected behavior
The SDK should gracefully handle string error responses and normalize them into an appropriate format before passing to ErrorException.
Suggested fix
Add a type check or JSON decode fallback in HttpTransporter::throwIfJsonError() before instantiating ErrorException.