Skip to content

Commit

Permalink
fix: evaluate httpPayload for s3 200 error
Browse files Browse the repository at this point in the history
Make sure that operations where any of its member has a httpPayload or streaming trait are ignored.
  • Loading branch information
yenfryherrerafeliz committed Aug 8, 2024
1 parent c8baf4f commit acd2b1d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/S3/Parser/S3Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function parse200Error(CommandInterface $command, ResponseInterface $res
{
// This error parsing should be just for 200 error responses and operations where its output shape
// does not have a streaming member.
if (200 !== $response->getStatusCode() || $this->hasStreamingTrait($command->getName())) {
if (200 !== $response->getStatusCode() || !$this->shouldBeConsidered200Error($command->getName())) {
return;
}

Expand Down Expand Up @@ -131,23 +131,27 @@ private function parse200Error(CommandInterface $command, ResponseInterface $res
}

/**
* Checks if a specific operation has a streaming trait.
* Checks if a specific operation should be considered
* a s3 200 error. Operations where any of its output members
* has a streaming or httpPayload trait should be not considered.
*
* @param $commandName
*
* @return bool
*/
private function hasStreamingTrait($commandName): bool
private function shouldBeConsidered200Error($commandName): bool
{
$operation = $this->api->getOperation($commandName);
$output = $operation->getOutput();
foreach ($output->getMembers() as $_ => $memberProps) {
if (!empty($memberProps['eventstream']) || !empty($memberProps['streaming'])) {
return true;
if (!empty($memberProps['eventstream'])
|| !empty($memberProps['streaming'])
|| !empty($memberProps['httpPayload'])) {
return false;
}
}

return false;
return true;
}

/**
Expand Down

0 comments on commit acd2b1d

Please sign in to comment.