Skip to content

Commit aefae54

Browse files
authored
Fix: validate trace id (#2749)
1 parent 006bdf6 commit aefae54

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
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 errors in recursion detection when `_X_AMZN_TRACE_ID` is unset (#2748).
5+
46
3.136.0 (2022-08-25)
57
------------------
68

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def call(context)
2020

2121
private
2222
def validate_header(header_value)
23+
return unless header_value
24+
2325
if (header_value.chars & (0..31).map(&:chr)).any?
2426
raise ArgumentError, 'Invalid _X_AMZN_TRACE_ID value: '\
2527
'contains ASCII control characters'

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ module Plugins
9999
end
100100
end
101101
end
102+
103+
context 'X_AMZ_TRACE_ID is unset' do
104+
let(:env_trace_id) { nil }
105+
106+
it 'does not set the header' do
107+
resp = client.operation_with_trace_id
108+
expect(resp.context.http_request.headers['x-amzn-trace-id']).to be_nil
109+
end
110+
end
102111
end
103112
end
104113
end

0 commit comments

Comments
 (0)