Describe the bug
When making a request which uses ['@http' => ['stream' => true]], if the server returns a HTTP error status such as 400, the SDK is unable to read the response body for inclusion in the exception message, and consequently there's no way to see the reason for the error.
Regression Issue
Expected Behavior
The PHP exception should include the error message from the HTTP body, as in non-streaming mode.
Fatal error: Uncaught exception 'Aws\BedrockRuntime\Exception\BedrockRuntimeException' with message 'Error executing "ConverseStream" on "https://bedrock-runtime.us-west-2.amazonaws.com/model/x/converse-stream"; AWS HTTP error: Client error: `POST https://bedrock-runtime.us-west-2.amazonaws.com/model/x/converse-stream` resulted in a `400 Bad Request` response:
{"message":"The provided model identifier is invalid."}
Current Behavior
The PHP exception says Unable to parse error information from response.
Fatal error: Uncaught exception 'Aws\BedrockRuntime\Exception\BedrockRuntimeException' with message 'Error executing "ConverseStream" on "https://bedrock-runtime.us-west-2.amazonaws.com/model/x/converse-stream"; AWS HTTP error: Client error: `POST https://bedrock-runtime.us-west-2.amazonaws.com/model/x/converse-stream` resulted in a `400 Bad Request` response Unable to parse error information from response - Error parsing JSON: Syntax error'
Reproduction Steps
Make a streaming API call, with some invalid parameters so that it would cause a 400 Bad Request response.
$client = new Aws\BedrockRuntime\BedrockRuntimeClient([
'version' => '2023-09-30',
'region' => 'us-west-2',
]);
$client->converseStream([
'modelId' => 'x',
'@http' => [
'stream' => true,
],
]);
Possible Solution
This could be because the response body stream is non-seekable, and some other part of the SDK has already read it.
Additional Information/Context
No response
SDK version used
3.343.14
Environment details (Version of PHP (php -v)? OS name and version, etc.)
PHP 8.1.31, Linux
Describe the bug
When making a request which uses
['@http' => ['stream' => true]], if the server returns a HTTP error status such as400, the SDK is unable to read the response body for inclusion in the exception message, and consequently there's no way to see the reason for the error.Regression Issue
Expected Behavior
The PHP exception should include the error message from the HTTP body, as in non-streaming mode.
Current Behavior
The PHP exception says
Unable to parse error information from response.Reproduction Steps
Make a streaming API call, with some invalid parameters so that it would cause a 400 Bad Request response.
Possible Solution
This could be because the response body stream is non-seekable, and some other part of the SDK has already read it.
Additional Information/Context
No response
SDK version used
3.343.14
Environment details (Version of PHP (
php -v)? OS name and version, etc.)PHP 8.1.31, Linux