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
When parsing an API response, it is structured as an Aws\Api\Parser\EventParsingIterator, and parses each event within the iterator when the current element is fetched.
An event type of error is handled:
if ($event['headers'][':message-type'] === 'error') {
return$this->parseError($event);
}
However, if the event type is exception, a ParserException is thrown:
if ($event['headers'][':message-type'] !== 'event') {
thrownewParserException('Failed to parse unknown message type.');
}
It's then, without modification of the library code itself, not possible to retrieve the actual exception details from the response. For example, when dumping the event and stream content before the throw, the actual exception is that the Lambda function failed on this occasion:
Expected Behavior
If there's an exception event, with a JSON payload, it should be decoded and returned - instead of throwing an exception with no way to obtain the actual exception/payload details.
Current Behavior
A ParserException is thrown.
Reproduction Steps
In my specific case,
AWS Bedrock Agent configured with an OpenAPI specification
Lambda function handling API proxy
The API call returns a 500 error, or the lambda function fails
ParserException is thrown when trying to extract data from the response.
Possible Solution
Implement a:
if ($event['headers'][':message-type'] === 'exception') {
return$this->handleException($event);
}
Additional Information/Context
No response
SDK version used
3.306.7, but is the same logic on the main branch
Environment details (Version of PHP (php -v)? OS name and version, etc.)
php 8.2
The text was updated successfully, but these errors were encountered:
Describe the bug
When parsing an API response, it is structured as an
Aws\Api\Parser\EventParsingIterator
, and parses each event within the iterator when the current element is fetched.An event type of
error
is handled:However, if the event type is
exception
, a ParserException is thrown:It's then, without modification of the library code itself, not possible to retrieve the actual exception details from the response. For example, when dumping the event and stream content before the
throw
, the actual exception is that the Lambda function failed on this occasion:Expected Behavior
If there's an exception event, with a JSON payload, it should be decoded and returned - instead of throwing an exception with no way to obtain the actual exception/payload details.
Current Behavior
A ParserException is thrown.
Reproduction Steps
In my specific case,
ParserException
is thrown when trying to extract data from the response.Possible Solution
Implement a:
Additional Information/Context
No response
SDK version used
3.306.7, but is the same logic on the main branch
Environment details (Version of PHP (
php -v
)? OS name and version, etc.)php 8.2
The text was updated successfully, but these errors were encountered: