aws-sdk-core 3.226.1 → 3.226.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2ca0fbdedab1c093c716160e76303794d1546fb910732e7399158149393379d
4
- data.tar.gz: 80287b842e9382353bb5c5093495299d8bfefaa4c1ca41227e34eeb2cb0ee592
3
+ metadata.gz: bcc66e64079950ab715bf739b9731f997c9d5c933dc6bf1a5a14c30afdf8e640
4
+ data.tar.gz: 239c2f96e5984261f5a020a2c219a24f80ccfbeba99ac9f71374d06924728d9f
5
5
  SHA512:
6
- metadata.gz: 95520dcd178c17ffee6588d5c840dcab71184746d1b3b9262de70a43a9fb2fb43ba0e773c6d4dcf08cdc0fc7639b407a644050e002edf34dc288077577e2577a
7
- data.tar.gz: 963666144b4c5f8f9826a667060e371b73772fa3fae57066cbcac775bc8a56a6e12350984bce5241a90e53d8e29f95e6be78b472c53a319af6b56b15a51f3bc3
6
+ metadata.gz: dac55de1f81dd26a15940cda1d4c7769aa7d3de2a5a02201c5c965caecd9ddf42fe9158ef16be0b1ec6c1d36ada3fface779f524e769b4ba3153e024eb272ccf
7
+ data.tar.gz: f157a62c531b7c3a6ae39f8ef4826161ef5641790d519658e9098571c5bee32f54fc149ae744a799a2e2550ffeb9269a0b23aed0b037368619337ae7e29e2063
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.226.3 (2025-07-17)
5
+ ------------------
6
+
7
+ * Issue - Skip `Aws::InstanceProfileCredentials` instantiation when `ENV['AWS_EC2_METADATA_DISABLED']` is set to `true` in the credential resolution chain.
8
+
9
+ * Issue - Refactor `InstanceProfileCredentials` to improve code clarity and documentation.
10
+
11
+ 3.226.2 (2025-07-01)
12
+ ------------------
13
+
14
+ * Issue - Document incorrect behavior in protocol error parsing (specifically around query and query compatible services).
15
+
4
16
  3.226.1 (2025-06-24)
5
17
  ------------------
6
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.226.1
1
+ 3.226.3
@@ -191,7 +191,7 @@ module Aws
191
191
  if ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] ||
192
192
  ENV['AWS_CONTAINER_CREDENTIALS_FULL_URI']
193
193
  ECSCredentials.new(options)
194
- else
194
+ elsif !(ENV.fetch('AWS_EC2_METADATA_DISABLED', 'false').downcase == 'true')
195
195
  InstanceProfileCredentials.new(options.merge(profile: profile_name))
196
196
  end
197
197
  end
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aws
4
+ # @api private
4
5
  class ErrorHandler < Seahorse::Client::Handler
5
6
 
6
7
  private
7
8
 
8
9
  def error(context)
9
10
  body = context.http_response.body_contents
11
+ # This is not correct per protocol tests. Some headers will determine the error code.
12
+ # If the body is empty, there is still potentially an error code from the header, but
13
+ # we are making a generic http status error instead. In a new major version, we should
14
+ # always try to extract header, and during extraction, check headers and body.
10
15
  if body.empty?
11
16
  code, message, data = http_status_error(context)
12
17
  else
@@ -4,11 +4,23 @@ require 'time'
4
4
  require 'net/http'
5
5
 
6
6
  module Aws
7
- # An auto-refreshing credential provider that loads credentials from
8
- # EC2 instances.
7
+ # An auto-refreshing credential provider that loads credentials from EC2 instances.
9
8
  #
10
9
  # instance_credentials = Aws::InstanceProfileCredentials.new
11
10
  # ec2 = Aws::EC2::Client.new(credentials: instance_credentials)
11
+ #
12
+ # ## Retries
13
+ # When initialized from the default credential chain, this provider defaults to `0` retries.
14
+ # Breakdown of retries is as follows:
15
+ #
16
+ # * **Configurable retries** (defaults to `1`): these retries handle errors when communicating
17
+ # with the IMDS endpoint. There are two separate retry mechanisms within the provider:
18
+ # * Entire token fetch and credential retrieval process
19
+ # * Token fetching
20
+ # * **JSON parsing retries**: Fixed at 3 attempts to handle cases when IMDS returns malformed JSON
21
+ # responses. These retries are separate from configurable retries.
22
+ #
23
+ # @see https://docs.aws.amazon.com/sdkref/latest/guide/feature-imds-credentials.html IMDS Credential Provider
12
24
  class InstanceProfileCredentials
13
25
  include CredentialProvider
14
26
  include RefreshingCredentials
@@ -22,10 +34,8 @@ module Aws
22
34
  # @api private
23
35
  class TokenExpiredError < RuntimeError; end
24
36
 
25
- # These are the errors we trap when attempting to talk to the
26
- # instance metadata service. Any of these imply the service
27
- # is not present, no responding or some other non-recoverable
28
- # error.
37
+ # These are the errors we trap when attempting to talk to the instance metadata service.
38
+ # Any of these imply the service is not present, no responding or some other non-recoverable error.
29
39
  # @api private
30
40
  NETWORK_ERRORS = [
31
41
  Errno::EHOSTUNREACH,
@@ -46,100 +56,113 @@ module Aws
46
56
  METADATA_TOKEN_PATH = '/latest/api/token'.freeze
47
57
 
48
58
  # @param [Hash] options
49
- # @option options [Integer] :retries (1) Number of times to retry
50
- # when retrieving credentials.
51
- # @option options [String] :endpoint ('http://169.254.169.254') The IMDS
52
- # endpoint. This option has precedence over the :endpoint_mode.
53
- # @option options [String] :endpoint_mode ('IPv4') The endpoint mode for
54
- # the instance metadata service. This is either 'IPv4' ('169.254.169.254')
55
- # or 'IPv6' ('[fd00:ec2::254]').
56
- # @option options [Boolean] :disable_imds_v1 (false) Disable the use of the
57
- # legacy EC2 Metadata Service v1.
58
- # @option options [String] :ip_address ('169.254.169.254') Deprecated. Use
59
- # :endpoint instead. The IP address for the endpoint.
59
+ # @option options [Integer] :retries (1) Number of times to retry when retrieving credentials.
60
+ # @option options [String] :endpoint ('http://169.254.169.254') The IMDS endpoint. This option has precedence
61
+ # over the `:endpoint_mode`.
62
+ # @option options [String] :endpoint_mode ('IPv4') The endpoint mode for the instance metadata service. This is
63
+ # either 'IPv4' (`169.254.169.254`) or IPv6' (`[fd00:ec2::254]`).
64
+ # @option options [Boolean] :disable_imds_v1 (false) Disable the use of the legacy EC2 Metadata Service v1.
65
+ # @option options [String] :ip_address ('169.254.169.254') Deprecated. Use `:endpoint` instead.
66
+ # The IP address for the endpoint.
60
67
  # @option options [Integer] :port (80)
61
68
  # @option options [Float] :http_open_timeout (1)
62
69
  # @option options [Float] :http_read_timeout (1)
63
- # @option options [Numeric, Proc] :delay By default, failures are retried
64
- # with exponential back-off, i.e. `sleep(1.2 ** num_failures)`. You can
65
- # pass a number of seconds to sleep between failed attempts, or
66
- # a Proc that accepts the number of failures.
67
- # @option options [IO] :http_debug_output (nil) HTTP wire
68
- # traces are sent to this object. You can specify something
69
- # like $stdout.
70
- # @option options [Integer] :token_ttl Time-to-Live in seconds for EC2
71
- # Metadata Token used for fetching Metadata Profile Credentials, defaults
72
- # to 21600 seconds
73
- # @option options [Callable] before_refresh Proc called before
74
- # credentials are refreshed. `before_refresh` is called
75
- # with an instance of this object when
76
- # AWS credentials are required and need to be refreshed.
70
+ # @option options [Numeric, Proc] :delay By default, failures are retried with exponential back-off, i.e.
71
+ # `sleep(1.2 ** num_failures)`. You can pass a number of seconds to sleep between failed attempts, or a Proc
72
+ # that accepts the number of failures.
73
+ # @option options [IO] :http_debug_output (nil) HTTP wire traces are sent to this object.
74
+ # You can specify something like `$stdout`.
75
+ # @option options [Integer] :token_ttl Time-to-Live in seconds for EC2 Metadata Token used for fetching
76
+ # Metadata Profile Credentials, defaults to 21600 seconds.
77
+ # @option options [Callable] :before_refresh Proc called before credentials are refreshed. `before_refresh`
78
+ # is called with an instance of this object when AWS credentials are required and need to be refreshed.
77
79
  def initialize(options = {})
78
- @retries = options[:retries] || 1
79
- endpoint_mode = resolve_endpoint_mode(options)
80
- @endpoint = resolve_endpoint(options, endpoint_mode)
81
- @port = options[:port] || 80
80
+ @backoff = resolve_backoff(options[:backoff])
82
81
  @disable_imds_v1 = resolve_disable_v1(options)
83
- # Flag for if v2 flow fails, skip future attempts
84
- @imds_v1_fallback = false
82
+ @endpoint = resolve_endpoint(options)
85
83
  @http_open_timeout = options[:http_open_timeout] || 1
86
84
  @http_read_timeout = options[:http_read_timeout] || 1
87
85
  @http_debug_output = options[:http_debug_output]
88
- @backoff = backoff(options[:backoff])
86
+ @port = options[:port] || 80
87
+ @retries = options[:retries] || 1
89
88
  @token_ttl = options[:token_ttl] || 21_600
90
- @token = nil
91
- @no_refresh_until = nil
89
+
92
90
  @async_refresh = false
91
+ @imds_v1_fallback = false
92
+ @no_refresh_until = nil
93
+ @token = nil
93
94
  @metrics = ['CREDENTIALS_IMDS']
94
95
  super
95
96
  end
96
97
 
97
- # @return [Integer] Number of times to retry when retrieving credentials
98
- # from the instance metadata service. Defaults to 0 when resolving from
99
- # the default credential chain ({Aws::CredentialProviderChain}).
98
+ # @return [Boolean0
99
+ attr_reader :disable_imds_v1
100
+
101
+ # @return [Integer]
102
+ attr_reader :token_ttl
103
+
104
+ # @return [Integer]
100
105
  attr_reader :retries
101
106
 
107
+ # @return [Proc]
108
+ attr_reader :backoff
109
+
110
+ # @return [String]
111
+ attr_reader :endpoint
112
+
113
+ # @return [Integer]
114
+ attr_reader :port
115
+
116
+ # @return [Integer]
117
+ attr_reader :http_open_timeout
118
+
119
+ # @return [Integer]
120
+ attr_reader :http_read_timeout
121
+
122
+ # @return [IO, nil]
123
+ attr_reader :http_debug_output
124
+
102
125
  private
103
126
 
104
127
  def resolve_endpoint_mode(options)
105
- value = options[:endpoint_mode]
106
- value ||= ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE']
107
- value ||= Aws.shared_config.ec2_metadata_service_endpoint_mode(
108
- profile: options[:profile]
109
- )
110
- value || 'IPv4'
128
+ options[:endpoint_mode] ||
129
+ ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE'] ||
130
+ Aws.shared_config.ec2_metadata_service_endpoint_mode(profile: options[:profile]) ||
131
+ 'IPv4'
111
132
  end
112
133
 
113
- def resolve_endpoint(options, endpoint_mode)
114
- value = options[:endpoint] || options[:ip_address]
115
- value ||= ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT']
116
- value ||= Aws.shared_config.ec2_metadata_service_endpoint(
117
- profile: options[:profile]
118
- )
134
+ def resolve_endpoint(options)
135
+ if (value = options[:ip_address])
136
+ warn('The `:ip_address` option is deprecated. Use `:endpoint` instead.')
137
+ return value
138
+ end
119
139
 
140
+ value =
141
+ options[:endpoint] ||
142
+ ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT'] ||
143
+ Aws.shared_config.ec2_metadata_service_endpoint(profile: options[:profile]) ||
144
+ nil
120
145
  return value if value
121
146
 
147
+ endpoint_mode = resolve_endpoint_mode(options)
122
148
  case endpoint_mode.downcase
123
149
  when 'ipv4' then 'http://169.254.169.254'
124
150
  when 'ipv6' then 'http://[fd00:ec2::254]'
125
151
  else
126
- raise ArgumentError,
127
- ':endpoint_mode is not valid, expected IPv4 or IPv6, '\
128
- "got: #{endpoint_mode}"
152
+ raise ArgumentError, ":endpoint_mode is not valid, expected IPv4 or IPv6, got: #{endpoint_mode}"
129
153
  end
130
154
  end
131
155
 
132
156
  def resolve_disable_v1(options)
133
- value = options[:disable_imds_v1]
134
- value ||= ENV['AWS_EC2_METADATA_V1_DISABLED']
135
- value ||= Aws.shared_config.ec2_metadata_v1_disabled(
136
- profile: options[:profile]
137
- )
138
- value = value.to_s.downcase if value
139
- Aws::Util.str_2_bool(value) || false
157
+ value =
158
+ options[:disable_imds_v1] ||
159
+ ENV['AWS_EC2_METADATA_V1_DISABLED'] ||
160
+ Aws.shared_config.ec2_metadata_v1_disabled(profile: options[:profile]) ||
161
+ 'false'
162
+ Aws::Util.str_2_bool(value.to_s.downcase)
140
163
  end
141
164
 
142
- def backoff(backoff)
165
+ def resolve_backoff(backoff)
143
166
  case backoff
144
167
  when Proc then backoff
145
168
  when Numeric then ->(_) { sleep(backoff) }
@@ -153,98 +176,74 @@ module Aws
153
176
  return
154
177
  end
155
178
 
156
- # Retry loading credentials up to 3 times is the instance metadata
157
- # service is responding but is returning invalid JSON documents
158
- # in response to the GET profile credentials call.
159
- begin
160
- retry_errors([Aws::Json::ParseError], max_retries: 3) do
161
- c = Aws::Json.load(get_credentials.to_s)
162
- if empty_credentials?(@credentials)
163
- @credentials = Credentials.new(
164
- c['AccessKeyId'],
165
- c['SecretAccessKey'],
166
- c['Token']
167
- )
168
- @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
169
- if @expiration && @expiration < Time.now
170
- @no_refresh_until = Time.now + refresh_offset
171
- warn_expired_credentials
172
- end
173
- else
174
- # credentials are already set, update them only if the new ones are not empty
175
- if !c['AccessKeyId'] || c['AccessKeyId'].empty?
176
- # error getting new credentials
177
- @no_refresh_until = Time.now + refresh_offset
178
- warn_expired_credentials
179
- else
180
- @credentials = Credentials.new(
181
- c['AccessKeyId'],
182
- c['SecretAccessKey'],
183
- c['Token']
184
- )
185
- @expiration = c['Expiration'] ? Time.iso8601(c['Expiration']) : nil
186
- if @expiration && @expiration < Time.now
187
- @no_refresh_until = Time.now + refresh_offset
188
- warn_expired_credentials
189
- end
190
- end
179
+ new_creds =
180
+ begin
181
+ # Retry loading credentials up to 3 times is the instance metadata
182
+ # service is responding but is returning invalid JSON documents
183
+ # in response to the GET profile credentials call.
184
+ retry_errors([Aws::Json::ParseError], max_retries: 3) do
185
+ Aws::Json.load(retrieve_credentials.to_s)
191
186
  end
187
+ rescue Aws::Json::ParseError
188
+ raise Aws::Errors::MetadataParserError
192
189
  end
193
- rescue Aws::Json::ParseError
194
- raise Aws::Errors::MetadataParserError
190
+
191
+ if @credentials&.set? && empty_credentials?(new_creds)
192
+ # credentials are already set, but there was an error getting new credentials
193
+ # so don't update the credentials and use stale ones (static stability)
194
+ @no_refresh_until = Time.now + rand(300..360)
195
+ warn_expired_credentials
196
+ else
197
+ # credentials are empty or successfully retrieved, update them
198
+ update_credentials(new_creds)
195
199
  end
196
200
  end
197
201
 
198
- def get_credentials
202
+ def retrieve_credentials
199
203
  # Retry loading credentials a configurable number of times if
200
204
  # the instance metadata service is not responding.
201
- if _metadata_disabled?
202
- '{}'
203
- else
204
- begin
205
- retry_errors(NETWORK_ERRORS, max_retries: @retries) do
206
- open_connection do |conn|
207
- # attempt to fetch token to start secure flow first
208
- # and rescue to failover
209
- fetch_token(conn) unless @imds_v1_fallback
210
- token = @token.value if token_set?
211
-
212
- # disable insecure flow if we couldn't get token
213
- # and imds v1 is disabled
214
- raise TokenRetrivalError if token.nil? && @disable_imds_v1
215
-
216
- _get_credentials(conn, token)
217
- end
205
+ begin
206
+ retry_errors(NETWORK_ERRORS, max_retries: @retries) do
207
+ open_connection do |conn|
208
+ # attempt to fetch token to start secure flow first
209
+ # and rescue to failover
210
+ fetch_token(conn) unless @imds_v1_fallback || (@token && !@token.expired?)
211
+
212
+ # disable insecure flow if we couldn't get token and imds v1 is disabled
213
+ raise TokenRetrivalError if @token.nil? && @disable_imds_v1
214
+
215
+ fetch_credentials(conn)
218
216
  end
219
- rescue => e
220
- warn("Error retrieving instance profile credentials: #{e}")
221
- '{}'
222
217
  end
218
+ rescue StandardError => e
219
+ warn("Error retrieving instance profile credentials: #{e}")
220
+ '{}'
223
221
  end
224
222
  end
225
223
 
224
+ def update_credentials(creds)
225
+ @credentials = Credentials.new(creds['AccessKeyId'], creds['SecretAccessKey'], creds['Token'])
226
+ @expiration = creds['Expiration'] ? Time.iso8601(creds['Expiration']) : nil
227
+ return unless @expiration && @expiration < Time.now
228
+
229
+ @no_refresh_until = Time.now + rand(300..360)
230
+ warn_expired_credentials
231
+ end
232
+
226
233
  def fetch_token(conn)
227
- retry_errors(NETWORK_ERRORS, max_retries: @retries) do
228
- unless token_set?
229
- created_time = Time.now
230
- token_value, ttl = http_put(
231
- conn, METADATA_TOKEN_PATH, @token_ttl
232
- )
233
- @token = Token.new(token_value, ttl, created_time) if token_value && ttl
234
- end
235
- end
234
+ created_time = Time.now
235
+ token_value, ttl = http_put(conn)
236
+ @token = Token.new(token_value, ttl, created_time) if token_value && ttl
236
237
  rescue *NETWORK_ERRORS
237
238
  # token attempt failed, reset token
238
239
  # fallback to non-token mode
239
- @token = nil
240
240
  @imds_v1_fallback = true
241
241
  end
242
242
 
243
- # token is optional - if nil, uses v1 (insecure) flow
244
- def _get_credentials(conn, token)
245
- metadata = http_get(conn, METADATA_PATH_BASE, token)
243
+ def fetch_credentials(conn)
244
+ metadata = http_get(conn, METADATA_PATH_BASE)
246
245
  profile_name = metadata.lines.first.strip
247
- http_get(conn, METADATA_PATH_BASE + profile_name, token)
246
+ http_get(conn, METADATA_PATH_BASE + profile_name)
248
247
  rescue TokenExpiredError
249
248
  # Token has expired, reset it
250
249
  # The next retry should fetch it
@@ -257,10 +256,6 @@ module Aws
257
256
  @token && !@token.expired?
258
257
  end
259
258
 
260
- def _metadata_disabled?
261
- ENV.fetch('AWS_EC2_METADATA_DISABLED', 'false').downcase == 'true'
262
- end
263
-
264
259
  def open_connection
265
260
  uri = URI.parse(@endpoint)
266
261
  http = Net::HTTP.new(uri.hostname || @endpoint, uri.port || @port)
@@ -272,9 +267,9 @@ module Aws
272
267
  end
273
268
 
274
269
  # GET request fetch profile and credentials
275
- def http_get(connection, path, token = nil)
270
+ def http_get(connection, path)
276
271
  headers = { 'User-Agent' => "aws-sdk-ruby3/#{CORE_GEM_VERSION}" }
277
- headers['x-aws-ec2-metadata-token'] = token if token
272
+ headers['x-aws-ec2-metadata-token'] = @token.value if @token
278
273
  response = connection.request(Net::HTTP::Get.new(path, headers))
279
274
 
280
275
  case response.code.to_i
@@ -288,12 +283,12 @@ module Aws
288
283
  end
289
284
 
290
285
  # PUT request fetch token with ttl
291
- def http_put(connection, path, ttl)
286
+ def http_put(connection)
292
287
  headers = {
293
288
  'User-Agent' => "aws-sdk-ruby3/#{CORE_GEM_VERSION}",
294
- 'x-aws-ec2-metadata-token-ttl-seconds' => ttl.to_s
289
+ 'x-aws-ec2-metadata-token-ttl-seconds' => @token_ttl.to_s
295
290
  }
296
- response = connection.request(Net::HTTP::Put.new(path, headers))
291
+ response = connection.request(Net::HTTP::Put.new(METADATA_TOKEN_PATH, headers))
297
292
  case response.code.to_i
298
293
  when 200
299
294
  [
@@ -322,18 +317,12 @@ module Aws
322
317
  end
323
318
 
324
319
  def warn_expired_credentials
325
- warn("Attempting credential expiration extension due to a credential "\
326
- "service availability issue. A refresh of these credentials "\
327
- "will be attempted again in 5 minutes.")
328
- end
329
-
330
- def empty_credentials?(creds)
331
- !creds || !creds.access_key_id || creds.access_key_id.empty?
320
+ warn('Attempting credential expiration extension due to a credential service availability issue. '\
321
+ 'A refresh of these credentials will be attempted again in 5 minutes.')
332
322
  end
333
323
 
334
- # Compute an offset for refresh with jitter
335
- def refresh_offset
336
- 300 + rand(0..60)
324
+ def empty_credentials?(creds_hash)
325
+ !creds_hash['AccessKeyId'] || creds_hash['AccessKeyId'].empty?
337
326
  end
338
327
 
339
328
  # @api private
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Aws
4
4
  module Json
5
+ # @api private
5
6
  class ErrorHandler < Aws::ErrorHandler
6
7
 
7
8
  def call(context)
@@ -24,18 +25,21 @@ module Aws
24
25
  end
25
26
 
26
27
  def error_code(json, context)
28
+ # This is not correct per protocol tests. awsQueryError is intended to populate the
29
+ # error code of the error class. The error class should come from __type. Query and
30
+ # query compatible services currently have dynamic errors raised from error codes instead
31
+ # of the modeled error class. However, changing this in this major version would break
32
+ # existing usage.
27
33
  code =
28
34
  if aws_query_error?(context)
29
- query_header = context.http_response.headers['x-amzn-query-error']
30
- error, _type = query_header.split(';') # type not supported
31
- remove_prefix(error, context)
35
+ aws_query_error_code(context)
32
36
  else
33
37
  json['__type']
34
38
  end
35
39
  code ||= json['code']
36
40
  code ||= context.http_response.headers['x-amzn-errortype']
37
41
  if code
38
- code.split('#').last
42
+ code.split('#').last.split(':').first
39
43
  else
40
44
  http_status_error_code(context)
41
45
  end
@@ -46,6 +50,12 @@ module Aws
46
50
  context.http_response.headers['x-amzn-query-error']
47
51
  end
48
52
 
53
+ def aws_query_error_code(context)
54
+ query_header = context.http_response.headers['x-amzn-query-error']
55
+ error, _type = query_header.split(';') # type not supported
56
+ remove_prefix(error, context)
57
+ end
58
+
49
59
  def remove_prefix(error_code, context)
50
60
  if (prefix = context.config.api.metadata['errorPrefix'])
51
61
  error_code.sub(/^#{prefix}/, '')
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Aws
4
4
  module RpcV2
5
+ # @api private
5
6
  class ErrorHandler < Aws::ErrorHandler
6
7
 
7
8
  def call(context)
@@ -37,11 +38,14 @@ module Aws
37
38
  end
38
39
 
39
40
  def error_code(data, context)
41
+ # This is not correct per protocol tests. awsQueryError is intended to populate the
42
+ # error code of the error class. The error class should come from __type. Query and
43
+ # query compatible services currently have dynamic errors raised from error codes instead
44
+ # of the modeled error class. However, changing this in this major version would break
45
+ # existing usage.
40
46
  code =
41
47
  if aws_query_error?(context)
42
- query_header = context.http_response.headers['x-amzn-query-error']
43
- error, _type = query_header.split(';') # type not supported
44
- remove_prefix(error, context)
48
+ aws_query_error_code(context)
45
49
  else
46
50
  data['__type']
47
51
  end
@@ -52,6 +56,25 @@ module Aws
52
56
  end
53
57
  end
54
58
 
59
+ def aws_query_error?(context)
60
+ context.config.api.metadata['awsQueryCompatible'] &&
61
+ context.http_response.headers['x-amzn-query-error']
62
+ end
63
+
64
+ def aws_query_error_code(context)
65
+ query_header = context.http_response.headers['x-amzn-query-error']
66
+ error, _type = query_header.split(';') # type not supported
67
+ remove_prefix(error, context)
68
+ end
69
+
70
+ def remove_prefix(error_code, context)
71
+ if (prefix = context.config.api.metadata['errorPrefix'])
72
+ error_code.sub(/^#{prefix}/, '')
73
+ else
74
+ error_code
75
+ end
76
+ end
77
+
55
78
  def parse_error_data(context, body, code)
56
79
  data = EmptyStructure.new
57
80
  if (error_rules = context.operation.errors)
@@ -67,19 +90,6 @@ module Aws
67
90
  end
68
91
  data
69
92
  end
70
-
71
- def aws_query_error?(context)
72
- context.config.api.metadata['awsQueryCompatible'] &&
73
- context.http_response.headers['x-amzn-query-error']
74
- end
75
-
76
- def remove_prefix(error_code, context)
77
- if (prefix = context.config.api.metadata['errorPrefix'])
78
- error_code.sub(/^#{prefix}/, '')
79
- else
80
- error_code
81
- end
82
- end
83
93
  end
84
94
  end
85
95
  end
@@ -5,6 +5,7 @@ require "cgi/util" if RUBY_VERSION < "3.5"
5
5
 
6
6
  module Aws
7
7
  module Xml
8
+ # @api private
8
9
  class ErrorHandler < Aws::ErrorHandler
9
10
 
10
11
  def call(context)
@@ -691,7 +691,7 @@ module Aws::SSO
691
691
  tracer: tracer
692
692
  )
693
693
  context[:gem_name] = 'aws-sdk-core'
694
- context[:gem_version] = '3.226.1'
694
+ context[:gem_version] = '3.226.3'
695
695
  Seahorse::Client::Request.new(handlers, context)
696
696
  end
697
697
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -56,7 +56,7 @@ module Aws::SSO
56
56
  autoload :EndpointProvider, 'aws-sdk-sso/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-sso/endpoints'
58
58
 
59
- GEM_VERSION = '3.226.1'
59
+ GEM_VERSION = '3.226.3'
60
60
 
61
61
  end
62
62
 
@@ -1061,7 +1061,7 @@ module Aws::SSOOIDC
1061
1061
  tracer: tracer
1062
1062
  )
1063
1063
  context[:gem_name] = 'aws-sdk-core'
1064
- context[:gem_version] = '3.226.1'
1064
+ context[:gem_version] = '3.226.3'
1065
1065
  Seahorse::Client::Request.new(handlers, context)
1066
1066
  end
1067
1067
 
@@ -56,7 +56,7 @@ module Aws::SSOOIDC
56
56
  autoload :EndpointProvider, 'aws-sdk-ssooidc/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-ssooidc/endpoints'
58
58
 
59
- GEM_VERSION = '3.226.1'
59
+ GEM_VERSION = '3.226.3'
60
60
 
61
61
  end
62
62
 
@@ -2594,7 +2594,7 @@ module Aws::STS
2594
2594
  tracer: tracer
2595
2595
  )
2596
2596
  context[:gem_name] = 'aws-sdk-core'
2597
- context[:gem_version] = '3.226.1'
2597
+ context[:gem_version] = '3.226.3'
2598
2598
  Seahorse::Client::Request.new(handlers, context)
2599
2599
  end
2600
2600
 
@@ -43,7 +43,6 @@ module Aws::STS
43
43
  #
44
44
  # Additionally, error classes are dynamically generated for service errors based on the error code
45
45
  # if they are not defined above.
46
- # Some existing error classes may use a different class name than the one documented.
47
46
  module Errors
48
47
 
49
48
  extend Aws::Errors::DynamicErrors
data/lib/aws-sdk-sts.rb CHANGED
@@ -56,7 +56,7 @@ module Aws::STS
56
56
  autoload :EndpointProvider, 'aws-sdk-sts/endpoint_provider'
57
57
  autoload :Endpoints, 'aws-sdk-sts/endpoints'
58
58
 
59
- GEM_VERSION = '3.226.1'
59
+ GEM_VERSION = '3.226.3'
60
60
 
61
61
  end
62
62
 
@@ -5,7 +5,7 @@ require 'stringio'
5
5
  module Seahorse
6
6
  module Client
7
7
  class RequestContext
8
-
8
+ # @param [Hash] options
9
9
  # @option options [required,Symbol] :operation_name (nil)
10
10
  # @option options [required,Model::Operation] :operation (nil)
11
11
  # @option options [Model::Authorizer] :authorizer (nil)
@@ -16,7 +16,7 @@ module Seahorse
16
16
  # @option options [Http::Response] :http_response (Http::Response.new)
17
17
  # @option options [Integer] :retries (0)
18
18
  # @option options [Aws::Telemetry::TracerBase] :tracer (Aws::Telemetry::NoOpTracer.new)
19
- # @options options [Hash] :metadata ({})
19
+ # @option options [Hash] :metadata ({})
20
20
  def initialize(options = {})
21
21
  @operation_name = options[:operation_name]
22
22
  @operation = options[:operation]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.226.1
4
+ version: 3.226.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services