Skip to content

Commit ded83d2

Browse files
authored
Fix typo in recursion detection - use AMZN instead of AMZ (#2740)
1 parent dc61dc2 commit ded83d2

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

gems/aws-sdk-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Fix typo in `RecursionDetection`, change amz to amzn in header and env name.
5+
46
3.131.5 (2022-07-28)
57
------------------
68

gems/aws-sdk-core/lib/aws-sdk-core/plugins/recursion_detection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class RecursionDetection < Seahorse::Client::Plugin
99
class Handler < Seahorse::Client::Handler
1010
def call(context)
1111

12-
unless context.http_request.headers.key?('x-amz-trace-id')
12+
unless context.http_request.headers.key?('x-amzn-trace-id')
1313
if ENV['AWS_LAMBDA_FUNCTION_NAME'] &&
14-
(trace_id = ENV['_X_AMZ_TRACE_ID'])
15-
context.http_request.headers['x-amz-trace-id'] = trace_id
14+
(trace_id = ENV['_X_AMZN_TRACE_ID'])
15+
context.http_request.headers['x-amzn-trace-id'] = trace_id
1616
end
1717
end
1818
@handler.call(context)

gems/aws-sdk-core/spec/aws/plugins/recursion_detection_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Plugins
2828
'TraceId' => {
2929
'shape' => 'String',
3030
'location' => "header",
31-
'locationName' => "x-amz-trace-id"
31+
'locationName' => "x-amzn-trace-id"
3232
}
3333
}
3434
},
@@ -47,21 +47,21 @@ module Plugins
4747
context 'no ENV variables set' do
4848
it 'does not set the header when ENV is not set' do
4949
resp = client.operation_with_trace_id
50-
expect(resp.context.http_request.headers.key?('x-amz-trace-id')).to be_falsey
50+
expect(resp.context.http_request.headers.key?('x-amzn-trace-id')).to be_falsey
5151
end
5252
end
5353

5454
context 'AWS_LAMBDA_FUNCTION_NAME is not set' do
5555
let(:env_trace_id) { 'Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1;lineage=a87bd80c:0,68fd508a:5,c512fbe3:2' }
5656
before do
5757
allow(ENV).to receive(:[]).and_return(nil)
58-
allow(ENV).to receive(:[]).with('_X_AMZ_TRACE_ID')
58+
allow(ENV).to receive(:[]).with('_X_AMZN_TRACE_ID')
5959
.and_return(env_trace_id)
6060
end
6161

6262
it 'does not set the header' do
6363
resp = client.operation_with_trace_id
64-
expect(resp.context.http_request.headers.key?('x-amz-trace-id')).to be_falsey
64+
expect(resp.context.http_request.headers.key?('x-amzn-trace-id')).to be_falsey
6565

6666
end
6767

@@ -73,19 +73,19 @@ module Plugins
7373
allow(ENV).to receive(:[]).and_return(nil)
7474
allow(ENV).to receive(:[]).with('AWS_LAMBDA_FUNCTION_NAME')
7575
.and_return(lambda_function_name)
76-
allow(ENV).to receive(:[]).with('_X_AMZ_TRACE_ID')
76+
allow(ENV).to receive(:[]).with('_X_AMZN_TRACE_ID')
7777
.and_return(env_trace_id)
7878
end
7979

8080
it 'sets the header' do
8181
resp = client.operation_with_trace_id
82-
expect(resp.context.http_request.headers['x-amz-trace-id']).to eq(env_trace_id)
82+
expect(resp.context.http_request.headers['x-amzn-trace-id']).to eq(env_trace_id)
8383
end
8484

8585
it 'does not override the header when the value is already set' do
8686
user_trace_id = "user_trace_id"
8787
resp = client.operation_with_trace_id(trace_id: user_trace_id)
88-
expect(resp.context.http_request.headers['x-amz-trace-id']).to eq(user_trace_id)
88+
expect(resp.context.http_request.headers['x-amzn-trace-id']).to eq(user_trace_id)
8989
end
9090
end
9191
end

0 commit comments

Comments
 (0)