-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issuequeuedThis issues is on the AWS team's backlogThis issues is on the AWS team's backlog
Description
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
- Select this option if this issue appears to be a regression.
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
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issuequeuedThis issues is on the AWS team's backlogThis issues is on the AWS team's backlog