aws-sdk-s3 1.210.0 → 1.210.1

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: 001f68c0fd317a05aecab1cd12673833d3321e9fdbf7f96bd0daf4e02030f305
4
- data.tar.gz: 27da581457ae45f288dec7f06ec74f088cf6593fa2eb788c2821ec3ee53574ea
3
+ metadata.gz: 0e35a4e9d931cc6326d6e11fe2e73d571a4ca8cf0b24060ec73793144dfd9e8c
4
+ data.tar.gz: 5b80f94ff3edaf8de3728282dd2220cbadfe3eb58c2c29bb0f4f0730f0c4a7a5
5
5
  SHA512:
6
- metadata.gz: 79e664dd1704d0bfe1c45cbddc72790e1d38ccd1d2b567b8442709feb07872eeafcb2160ecbd976d5e037a8c8ecdf904e5fbbd02295685ca43b192c2d4d7b3de
7
- data.tar.gz: 1e9dfe900fcc03eb10a8b63a8393890a6b281bf469fc3e0e8c661c9318171726a6fd8edd871376455b8754df9aba636dc1f58f1b1bb1b9b322ddc693af2f20c0
6
+ metadata.gz: 6107bf342199aee13b8a9b1fc13562c955a2efce427b8c57d34ed1fc98e7dc22ec16e2fc7e0480531141ff1e413f17fb63ec419f1068516624598758d783fb38
7
+ data.tar.gz: 0f2c903871fc55b830ee17ff090d831142d9d699220d93eae6005eedf2edb2a86519471803753af2e036e29795fdb928cf18271fddf229079940f4345a630106
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.210.1 (2026-01-06)
5
+ ------------------
6
+
7
+ * Issue - Normalize response encoding to UTF-8 for proper XML error parsing in HTTP 200 responses.
8
+
4
9
  1.210.0 (2026-01-05)
5
10
  ------------------
6
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.210.0
1
+ 1.210.1
@@ -22283,7 +22283,7 @@ module Aws::S3
22283
22283
  tracer: tracer
22284
22284
  )
22285
22285
  context[:gem_name] = 'aws-sdk-s3'
22286
- context[:gem_version] = '1.210.0'
22286
+ context[:gem_version] = '1.210.1'
22287
22287
  Seahorse::Client::Request.new(handlers, context)
22288
22288
  end
22289
22289
 
@@ -3,15 +3,28 @@
3
3
  module Aws
4
4
  module S3
5
5
  module Plugins
6
-
7
6
  # A handful of Amazon S3 operations will respond with a 200 status
8
7
  # code but will send an error in the response body. This plugin
9
8
  # injects a handler that will parse 200 response bodies for potential
10
9
  # errors, allowing them to be retried.
11
10
  # @api private
12
11
  class Http200Errors < Seahorse::Client::Plugin
13
-
14
12
  class Handler < Seahorse::Client::Handler
13
+ # A regular expression to match error codes in the response body
14
+ CODE_PATTERN = %r{<Code>(.+?)</Code>}.freeze
15
+ private_constant :CODE_PATTERN
16
+
17
+ # A list of encodings we force into UTF-8
18
+ ENCODINGS_TO_FIX = [Encoding::US_ASCII, Encoding::ASCII_8BIT].freeze
19
+ private_constant :ENCODINGS_TO_FIX
20
+
21
+ # A regular expression to match detect errors in the response body
22
+ ERROR_PATTERN = /<\?xml\s[^>]*\?>\s*<Error>/.freeze
23
+ private_constant :ERROR_PATTERN
24
+
25
+ # A regular expression to match an error message in the response body
26
+ MESSAGE_PATTERN = %r{<Message>(.+?)</Message>}.freeze
27
+ private_constant :MESSAGE_PATTERN
15
28
 
16
29
  def call(context)
17
30
  @handler.call(context).on(200) do |response|
@@ -28,29 +41,37 @@ module Aws
28
41
 
29
42
  private
30
43
 
31
- # Streaming outputs are not subject to 200 errors.
32
- def streaming_output?(output)
33
- if (payload = output[:payload_member])
34
- # checking ref and shape
35
- payload['streaming'] || payload.shape['streaming'] ||
36
- payload.eventstream
37
- else
38
- false
44
+ def build_error(context, code, message)
45
+ S3::Errors.error_class(code).new(context, message)
46
+ end
47
+
48
+ def check_for_error(context)
49
+ xml = normalize_encoding(context.http_response.body_contents)
50
+
51
+ if xml.match?(ERROR_PATTERN)
52
+ error_code = xml.match(CODE_PATTERN)[1]
53
+ error_message = xml.match(MESSAGE_PATTERN)[1]
54
+ build_error(context, error_code, error_message)
55
+ elsif incomplete_xml_body?(xml, context.operation.output)
56
+ Seahorse::Client::NetworkingError.new(
57
+ build_error(context, 'InternalError', 'Empty or incomplete response body')
58
+ )
39
59
  end
40
60
  end
41
61
 
62
+ # Must have a member in the body and have the start of an XML Tag.
63
+ # Other incomplete xml bodies will result in an XML ParsingError.
64
+ def incomplete_xml_body?(xml, output)
65
+ members_in_body?(output) && !xml.match(/<\w/)
66
+ end
67
+
42
68
  # Checks if the output shape is a structure shape and has members that
43
69
  # are in the body for the case of a payload and a normal structure. A
44
70
  # non-structure shape will not have members in the body. In the case
45
71
  # of a string or blob, the body contents would have been checked first
46
72
  # before this method is called in incomplete_xml_body?.
47
73
  def members_in_body?(output)
48
- shape =
49
- if output[:payload_member]
50
- output[:payload_member].shape
51
- else
52
- output.shape
53
- end
74
+ shape = resolve_shape(output)
54
75
 
55
76
  if structure_shape?(shape)
56
77
  shape.members.any? { |_, k| k.location.nil? }
@@ -59,30 +80,33 @@ module Aws
59
80
  end
60
81
  end
61
82
 
62
- def structure_shape?(shape)
63
- shape.is_a?(Seahorse::Model::Shapes::StructureShape)
83
+ # Fixes encoding issues when S3 returns UTF-8 content with missing charset in Content-Type header or omits
84
+ # Content-Type header entirely. Net::HTTP defaults to US-ASCII or ASCII-8BIT when charset is unspecified.
85
+ def normalize_encoding(xml)
86
+ return xml unless xml.is_a?(String) && ENCODINGS_TO_FIX.include?(xml.encoding)
87
+
88
+ xml.force_encoding('UTF-8')
64
89
  end
65
90
 
66
- # Must have a member in the body and have the start of an XML Tag.
67
- # Other incomplete xml bodies will result in an XML ParsingError.
68
- def incomplete_xml_body?(xml, output)
69
- members_in_body?(output) && !xml.match(/<\w/)
91
+ def resolve_shape(output)
92
+ return output.shape unless output[:payload_member]
93
+
94
+ output[:payload_member].shape
70
95
  end
71
96
 
72
- def check_for_error(context)
73
- xml = context.http_response.body_contents
74
- if xml.match(/<\?xml\s[^>]*\?>\s*<Error>/)
75
- error_code = xml.match(%r{<Code>(.+?)</Code>})[1]
76
- error_message = xml.match(%r{<Message>(.+?)</Message>})[1]
77
- S3::Errors.error_class(error_code).new(context, error_message)
78
- elsif incomplete_xml_body?(xml, context.operation.output)
79
- Seahorse::Client::NetworkingError.new(
80
- S3::Errors
81
- .error_class('InternalError')
82
- .new(context, 'Empty or incomplete response body')
83
- )
97
+ # Streaming outputs are not subject to 200 errors.
98
+ def streaming_output?(output)
99
+ if (payload = output[:payload_member])
100
+ # checking ref and shape
101
+ payload['streaming'] || payload.shape['streaming'] || payload.eventstream
102
+ else
103
+ false
84
104
  end
85
105
  end
106
+
107
+ def structure_shape?(shape)
108
+ shape.is_a?(Seahorse::Model::Shapes::StructureShape)
109
+ end
86
110
  end
87
111
 
88
112
  handler(Handler, step: :sign)
data/lib/aws-sdk-s3.rb CHANGED
@@ -75,7 +75,7 @@ module Aws::S3
75
75
  autoload :ObjectVersion, 'aws-sdk-s3/object_version'
76
76
  autoload :EventStreams, 'aws-sdk-s3/event_streams'
77
77
 
78
- GEM_VERSION = '1.210.0'
78
+ GEM_VERSION = '1.210.1'
79
79
 
80
80
  end
81
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.210.0
4
+ version: 1.210.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services