Skip to content

Commit

Permalink
Handle missing x-amz-target header
Browse files Browse the repository at this point in the history
In some cases - particularly on local environments `$request_id` can be truthy but empty, or without offset 0 being set, additionally the `x-amz-target` header isn't always set in requests to S3. This update ensures both cases don't cause warnings to be output but rather falls back to reasonable defaults.

A missing `x-amz-target` header will give `amz-unknown-target` as the value if it's not set.
  • Loading branch information
roborourke authored Jun 22, 2020
1 parent b125ef1 commit a151ce4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ function on_aws_guzzle_request_stats( TransferStats $stats ) {
],
],
'aws' => [
'request_id' => $request_id ? $request_id[0] : null,
'operation' => explode( '.', $stats->getRequest()->getHeader( 'x-amz-target' )[0] )[1],
'request_id' => $request_id[0] ?? null,
'operation' => explode( '.', $stats->getRequest()->getHeader( 'x-amz-target' )[0] ?? 'xray.amz-unknown-target' )[1],
],
'in_progress' => false,
'fault' => $code > 499,
Expand Down

0 comments on commit a151ce4

Please sign in to comment.