@aws-sdk/core 3.943.0 → 3.947.0

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.
package/dist-cjs/index.js CHANGED
@@ -18,15 +18,15 @@ const state = {
18
18
  warningEmitted: false,
19
19
  };
20
20
  const emitWarningIfUnsupportedVersion = (version) => {
21
- if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
21
+ if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 20) {
22
22
  state.warningEmitted = true;
23
23
  process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
24
- no longer support Node.js 16.x on January 6, 2025.
24
+ no longer support Node.js ${version} in January 2026.
25
25
 
26
26
  To continue receiving updates to AWS services, bug fixes, and security
27
27
  updates please upgrade to a supported Node.js LTS version.
28
28
 
29
- More information can be found at: https://a.co/74kJMmI`);
29
+ More information can be found at: https://a.co/c895JFp`);
30
30
  }
31
31
  };
32
32
 
@@ -406,9 +406,18 @@ class ProtocolLib {
406
406
  const msg = exception.Message ?? additions.Message;
407
407
  const error = smithyClient.decorateServiceException(exception, additions);
408
408
  if (msg) {
409
- error.Message = msg;
410
409
  error.message = msg;
411
410
  }
411
+ error.Error = {
412
+ ...error.Error,
413
+ Type: error.Error.Type,
414
+ Code: error.Error.Code,
415
+ Message: error.Error.message ?? error.Error.Message ?? msg,
416
+ };
417
+ const reqId = error.$metadata.requestId;
418
+ if (reqId) {
419
+ error.RequestId = reqId;
420
+ }
412
421
  return error;
413
422
  }
414
423
  return smithyClient.decorateServiceException(exception, additions);
@@ -424,7 +433,7 @@ class ProtocolLib {
424
433
  };
425
434
  Object.assign(output, Error);
426
435
  for (const [k, v] of entries) {
427
- Error[k] = v;
436
+ Error[k === "message" ? "Message" : k] = v;
428
437
  }
429
438
  delete Error.__type;
430
439
  output.Error = Error;
@@ -441,6 +450,14 @@ class ProtocolLib {
441
450
  errorData.Code = queryCompatErrorData.Code;
442
451
  }
443
452
  }
453
+ findQueryCompatibleError(registry, errorName) {
454
+ try {
455
+ return registry.getSchema(errorName);
456
+ }
457
+ catch (e) {
458
+ return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
459
+ }
460
+ }
444
461
  }
445
462
 
446
463
  class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
@@ -462,15 +479,23 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
462
479
  if (this.awsQueryCompatible) {
463
480
  this.mixin.setQueryCompatError(dataObject, response);
464
481
  }
465
- const errorName = cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
466
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
482
+ const errorName = (() => {
483
+ const compatHeader = response.headers["x-amzn-query-error"];
484
+ if (compatHeader && this.awsQueryCompatible) {
485
+ return compatHeader.split(";")[0];
486
+ }
487
+ return cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
488
+ })();
489
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
467
490
  const ns = schema.NormalizedSchema.of(errorSchema);
468
491
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
469
492
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
470
493
  const exception = new ErrorCtor(message);
471
494
  const output = {};
472
495
  for (const [name, member] of ns.structIterator()) {
473
- output[name] = this.deserializer.readValue(member, dataObject[name]);
496
+ if (dataObject[name] != null) {
497
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
498
+ }
474
499
  }
475
500
  if (this.awsQueryCompatible) {
476
501
  this.mixin.queryCompatOutput(dataObject, output);
@@ -1035,15 +1060,16 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
1035
1060
  this.mixin.setQueryCompatError(dataObject, response);
1036
1061
  }
1037
1062
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
1038
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
1063
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
1039
1064
  const ns = schema.NormalizedSchema.of(errorSchema);
1040
1065
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
1041
1066
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
1042
1067
  const exception = new ErrorCtor(message);
1043
1068
  const output = {};
1044
1069
  for (const [name, member] of ns.structIterator()) {
1045
- const target = member.getMergedTraits().jsonName ?? name;
1046
- output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
1070
+ if (dataObject[name] != null) {
1071
+ output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
1072
+ }
1047
1073
  }
1048
1074
  if (this.awsQueryCompatible) {
1049
1075
  this.mixin.queryCompatOutput(dataObject, output);
@@ -1563,18 +1589,13 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
1563
1589
  Code: errorData.Code,
1564
1590
  Message: message,
1565
1591
  };
1566
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => {
1567
- try {
1568
- return registry.getSchema(errorName);
1569
- }
1570
- catch (e) {
1571
- return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
1572
- }
1573
- });
1592
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
1574
1593
  const ns = schema.NormalizedSchema.of(errorSchema);
1575
1594
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
1576
1595
  const exception = new ErrorCtor(message);
1577
1596
  const output = {
1597
+ Type: errorData.Error.Type,
1598
+ Code: errorData.Error.Code,
1578
1599
  Error: errorData.Error,
1579
1600
  };
1580
1601
  for (const [name, member] of ns.structIterator()) {
@@ -1995,10 +2016,11 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
1995
2016
  request.headers["content-type"] = contentType;
1996
2017
  }
1997
2018
  }
1998
- if (request.headers["content-type"] === this.getDefaultContentType()) {
1999
- if (typeof request.body === "string") {
2000
- request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
2001
- }
2019
+ if (typeof request.body === "string" &&
2020
+ request.headers["content-type"] === this.getDefaultContentType() &&
2021
+ !request.body.startsWith("<?xml ") &&
2022
+ !this.hasUnstructuredPayloadBinding(inputSchema)) {
2023
+ request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
2002
2024
  }
2003
2025
  return request;
2004
2026
  }
@@ -2027,6 +2049,14 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
2027
2049
  getDefaultContentType() {
2028
2050
  return "application/xml";
2029
2051
  }
2052
+ hasUnstructuredPayloadBinding(ns) {
2053
+ for (const [, member] of ns.structIterator()) {
2054
+ if (member.getMergedTraits().httpPayload) {
2055
+ return !(member.isStructSchema() || member.isMapSchema() || member.isListSchema());
2056
+ }
2057
+ }
2058
+ return false;
2059
+ }
2030
2060
  }
2031
2061
 
2032
2062
  exports.AWSSDKSigV4Signer = AWSSDKSigV4Signer;
@@ -4,15 +4,15 @@ const state = {
4
4
  warningEmitted: false,
5
5
  };
6
6
  const emitWarningIfUnsupportedVersion = (version) => {
7
- if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
7
+ if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 20) {
8
8
  state.warningEmitted = true;
9
9
  process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
10
- no longer support Node.js 16.x on January 6, 2025.
10
+ no longer support Node.js ${version} in January 2026.
11
11
 
12
12
  To continue receiving updates to AWS services, bug fixes, and security
13
13
  updates please upgrade to a supported Node.js LTS version.
14
14
 
15
- More information can be found at: https://a.co/74kJMmI`);
15
+ More information can be found at: https://a.co/c895JFp`);
16
16
  }
17
17
  };
18
18
 
@@ -76,9 +76,18 @@ class ProtocolLib {
76
76
  const msg = exception.Message ?? additions.Message;
77
77
  const error = smithyClient.decorateServiceException(exception, additions);
78
78
  if (msg) {
79
- error.Message = msg;
80
79
  error.message = msg;
81
80
  }
81
+ error.Error = {
82
+ ...error.Error,
83
+ Type: error.Error.Type,
84
+ Code: error.Error.Code,
85
+ Message: error.Error.message ?? error.Error.Message ?? msg,
86
+ };
87
+ const reqId = error.$metadata.requestId;
88
+ if (reqId) {
89
+ error.RequestId = reqId;
90
+ }
82
91
  return error;
83
92
  }
84
93
  return smithyClient.decorateServiceException(exception, additions);
@@ -94,7 +103,7 @@ class ProtocolLib {
94
103
  };
95
104
  Object.assign(output, Error);
96
105
  for (const [k, v] of entries) {
97
- Error[k] = v;
106
+ Error[k === "message" ? "Message" : k] = v;
98
107
  }
99
108
  delete Error.__type;
100
109
  output.Error = Error;
@@ -111,6 +120,14 @@ class ProtocolLib {
111
120
  errorData.Code = queryCompatErrorData.Code;
112
121
  }
113
122
  }
123
+ findQueryCompatibleError(registry, errorName) {
124
+ try {
125
+ return registry.getSchema(errorName);
126
+ }
127
+ catch (e) {
128
+ return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
129
+ }
130
+ }
114
131
  }
115
132
 
116
133
  class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
@@ -132,15 +149,23 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
132
149
  if (this.awsQueryCompatible) {
133
150
  this.mixin.setQueryCompatError(dataObject, response);
134
151
  }
135
- const errorName = cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
136
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
152
+ const errorName = (() => {
153
+ const compatHeader = response.headers["x-amzn-query-error"];
154
+ if (compatHeader && this.awsQueryCompatible) {
155
+ return compatHeader.split(";")[0];
156
+ }
157
+ return cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
158
+ })();
159
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
137
160
  const ns = schema.NormalizedSchema.of(errorSchema);
138
161
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
139
162
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
140
163
  const exception = new ErrorCtor(message);
141
164
  const output = {};
142
165
  for (const [name, member] of ns.structIterator()) {
143
- output[name] = this.deserializer.readValue(member, dataObject[name]);
166
+ if (dataObject[name] != null) {
167
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
168
+ }
144
169
  }
145
170
  if (this.awsQueryCompatible) {
146
171
  this.mixin.queryCompatOutput(dataObject, output);
@@ -705,15 +730,16 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
705
730
  this.mixin.setQueryCompatError(dataObject, response);
706
731
  }
707
732
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
708
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
733
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
709
734
  const ns = schema.NormalizedSchema.of(errorSchema);
710
735
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
711
736
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
712
737
  const exception = new ErrorCtor(message);
713
738
  const output = {};
714
739
  for (const [name, member] of ns.structIterator()) {
715
- const target = member.getMergedTraits().jsonName ?? name;
716
- output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
740
+ if (dataObject[name] != null) {
741
+ output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
742
+ }
717
743
  }
718
744
  if (this.awsQueryCompatible) {
719
745
  this.mixin.queryCompatOutput(dataObject, output);
@@ -1233,18 +1259,13 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
1233
1259
  Code: errorData.Code,
1234
1260
  Message: message,
1235
1261
  };
1236
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => {
1237
- try {
1238
- return registry.getSchema(errorName);
1239
- }
1240
- catch (e) {
1241
- return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
1242
- }
1243
- });
1262
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
1244
1263
  const ns = schema.NormalizedSchema.of(errorSchema);
1245
1264
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
1246
1265
  const exception = new ErrorCtor(message);
1247
1266
  const output = {
1267
+ Type: errorData.Error.Type,
1268
+ Code: errorData.Error.Code,
1248
1269
  Error: errorData.Error,
1249
1270
  };
1250
1271
  for (const [name, member] of ns.structIterator()) {
@@ -1665,10 +1686,11 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
1665
1686
  request.headers["content-type"] = contentType;
1666
1687
  }
1667
1688
  }
1668
- if (request.headers["content-type"] === this.getDefaultContentType()) {
1669
- if (typeof request.body === "string") {
1670
- request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
1671
- }
1689
+ if (typeof request.body === "string" &&
1690
+ request.headers["content-type"] === this.getDefaultContentType() &&
1691
+ !request.body.startsWith("<?xml ") &&
1692
+ !this.hasUnstructuredPayloadBinding(inputSchema)) {
1693
+ request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
1672
1694
  }
1673
1695
  return request;
1674
1696
  }
@@ -1697,6 +1719,14 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
1697
1719
  getDefaultContentType() {
1698
1720
  return "application/xml";
1699
1721
  }
1722
+ hasUnstructuredPayloadBinding(ns) {
1723
+ for (const [, member] of ns.structIterator()) {
1724
+ if (member.getMergedTraits().httpPayload) {
1725
+ return !(member.isStructSchema() || member.isMapSchema() || member.isListSchema());
1726
+ }
1727
+ }
1728
+ return false;
1729
+ }
1700
1730
  }
1701
1731
 
1702
1732
  exports.AwsEc2QueryProtocol = AwsEc2QueryProtocol;
@@ -2,14 +2,14 @@ export const state = {
2
2
  warningEmitted: false,
3
3
  };
4
4
  export const emitWarningIfUnsupportedVersion = (version) => {
5
- if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
5
+ if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 20) {
6
6
  state.warningEmitted = true;
7
7
  process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
8
- no longer support Node.js 16.x on January 6, 2025.
8
+ no longer support Node.js ${version} in January 2026.
9
9
 
10
10
  To continue receiving updates to AWS services, bug fixes, and security
11
11
  updates please upgrade to a supported Node.js LTS version.
12
12
 
13
- More information can be found at: https://a.co/74kJMmI`);
13
+ More information can be found at: https://a.co/c895JFp`);
14
14
  }
15
15
  };
@@ -1,4 +1,4 @@
1
- import { TypeRegistry } from "@smithy/core/schema";
1
+ import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
2
2
  import { decorateServiceException } from "@smithy/smithy-client";
3
3
  export class ProtocolLib {
4
4
  queryCompat;
@@ -67,9 +67,18 @@ export class ProtocolLib {
67
67
  const msg = exception.Message ?? additions.Message;
68
68
  const error = decorateServiceException(exception, additions);
69
69
  if (msg) {
70
- error.Message = msg;
71
70
  error.message = msg;
72
71
  }
72
+ error.Error = {
73
+ ...error.Error,
74
+ Type: error.Error.Type,
75
+ Code: error.Error.Code,
76
+ Message: error.Error.message ?? error.Error.Message ?? msg,
77
+ };
78
+ const reqId = error.$metadata.requestId;
79
+ if (reqId) {
80
+ error.RequestId = reqId;
81
+ }
73
82
  return error;
74
83
  }
75
84
  return decorateServiceException(exception, additions);
@@ -85,7 +94,7 @@ export class ProtocolLib {
85
94
  };
86
95
  Object.assign(output, Error);
87
96
  for (const [k, v] of entries) {
88
- Error[k] = v;
97
+ Error[k === "message" ? "Message" : k] = v;
89
98
  }
90
99
  delete Error.__type;
91
100
  output.Error = Error;
@@ -102,4 +111,12 @@ export class ProtocolLib {
102
111
  errorData.Code = queryCompatErrorData.Code;
103
112
  }
104
113
  }
114
+ findQueryCompatibleError(registry, errorName) {
115
+ try {
116
+ return registry.getSchema(errorName);
117
+ }
118
+ catch (e) {
119
+ return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
120
+ }
121
+ }
105
122
  }
@@ -20,15 +20,23 @@ export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
20
20
  if (this.awsQueryCompatible) {
21
21
  this.mixin.setQueryCompatError(dataObject, response);
22
22
  }
23
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
24
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
23
+ const errorName = (() => {
24
+ const compatHeader = response.headers["x-amzn-query-error"];
25
+ if (compatHeader && this.awsQueryCompatible) {
26
+ return compatHeader.split(";")[0];
27
+ }
28
+ return loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
29
+ })();
30
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
25
31
  const ns = NormalizedSchema.of(errorSchema);
26
32
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
27
33
  const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
28
34
  const exception = new ErrorCtor(message);
29
35
  const output = {};
30
36
  for (const [name, member] of ns.structIterator()) {
31
- output[name] = this.deserializer.readValue(member, dataObject[name]);
37
+ if (dataObject[name] != null) {
38
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
39
+ }
32
40
  }
33
41
  if (this.awsQueryCompatible) {
34
42
  this.mixin.queryCompatOutput(dataObject, output);
@@ -54,15 +54,16 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
54
54
  this.mixin.setQueryCompatError(dataObject, response);
55
55
  }
56
56
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
57
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
57
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
58
58
  const ns = NormalizedSchema.of(errorSchema);
59
59
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
60
60
  const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
61
61
  const exception = new ErrorCtor(message);
62
62
  const output = {};
63
63
  for (const [name, member] of ns.structIterator()) {
64
- const target = member.getMergedTraits().jsonName ?? name;
65
- output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
64
+ if (dataObject[name] != null) {
65
+ output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
66
+ }
66
67
  }
67
68
  if (this.awsQueryCompatible) {
68
69
  this.mixin.queryCompatOutput(dataObject, output);
@@ -95,18 +95,13 @@ export class AwsQueryProtocol extends RpcProtocol {
95
95
  Code: errorData.Code,
96
96
  Message: message,
97
97
  };
98
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => {
99
- try {
100
- return registry.getSchema(errorName);
101
- }
102
- catch (e) {
103
- return registry.find((schema) => NormalizedSchema.of(schema).getMergedTraits().awsQueryError?.[0] === errorName);
104
- }
105
- });
98
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
106
99
  const ns = NormalizedSchema.of(errorSchema);
107
100
  const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
108
101
  const exception = new ErrorCtor(message);
109
102
  const output = {
103
+ Type: errorData.Error.Type,
104
+ Code: errorData.Error.Code,
110
105
  Error: errorData.Error,
111
106
  };
112
107
  for (const [name, member] of ns.structIterator()) {
@@ -38,10 +38,11 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
38
38
  request.headers["content-type"] = contentType;
39
39
  }
40
40
  }
41
- if (request.headers["content-type"] === this.getDefaultContentType()) {
42
- if (typeof request.body === "string") {
43
- request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
44
- }
41
+ if (typeof request.body === "string" &&
42
+ request.headers["content-type"] === this.getDefaultContentType() &&
43
+ !request.body.startsWith("<?xml ") &&
44
+ !this.hasUnstructuredPayloadBinding(inputSchema)) {
45
+ request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
45
46
  }
46
47
  return request;
47
48
  }
@@ -70,4 +71,12 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
70
71
  getDefaultContentType() {
71
72
  return "application/xml";
72
73
  }
74
+ hasUnstructuredPayloadBinding(ns) {
75
+ for (const [, member] of ns.structIterator()) {
76
+ if (member.getMergedTraits().httpPayload) {
77
+ return !(member.isStructSchema() || member.isMapSchema() || member.isListSchema());
78
+ }
79
+ }
80
+ return false;
81
+ }
73
82
  }
@@ -51,5 +51,11 @@ export declare class ProtocolLib {
51
51
  * @param errorData - canonical error object returned to the caller.
52
52
  */
53
53
  queryCompatOutput(queryCompatErrorData: any, errorData: any): void;
54
+ /**
55
+ * Finds the canonical modeled error using the awsQueryError alias.
56
+ * @param registry - service error registry.
57
+ * @param errorName - awsQueryError name or regular qualified shapeId.
58
+ */
59
+ findQueryCompatibleError(registry: TypeRegistry, errorName: string): StaticErrorSchema;
54
60
  }
55
61
  export {};
@@ -25,4 +25,5 @@ export declare class AwsRestXmlProtocol extends HttpBindingProtocol {
25
25
  * @override
26
26
  */
27
27
  protected getDefaultContentType(): string;
28
+ private hasUnstructuredPayloadBinding;
28
29
  }
@@ -39,5 +39,9 @@ export declare class ProtocolLib {
39
39
  response: IHttpResponse
40
40
  ): void;
41
41
  queryCompatOutput(queryCompatErrorData: any, errorData: any): void;
42
+ findQueryCompatibleError(
43
+ registry: TypeRegistry,
44
+ errorName: string
45
+ ): StaticErrorSchema;
42
46
  }
43
47
  export {};
@@ -38,4 +38,5 @@ export declare class AwsRestXmlProtocol extends HttpBindingProtocol {
38
38
  metadata: ResponseMetadata
39
39
  ): Promise<never>;
40
40
  protected getDefaultContentType(): string;
41
+ private hasUnstructuredPayloadBinding;
41
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.943.0",
3
+ "version": "3.947.0",
4
4
  "description": "Core functions & classes shared by multiple AWS SDK clients.",
5
5
  "scripts": {
6
6
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
@@ -83,12 +83,12 @@
83
83
  "dependencies": {
84
84
  "@aws-sdk/types": "3.936.0",
85
85
  "@aws-sdk/xml-builder": "3.930.0",
86
- "@smithy/core": "^3.18.5",
86
+ "@smithy/core": "^3.18.7",
87
87
  "@smithy/node-config-provider": "^4.3.5",
88
88
  "@smithy/property-provider": "^4.2.5",
89
89
  "@smithy/protocol-http": "^5.3.5",
90
90
  "@smithy/signature-v4": "^5.3.5",
91
- "@smithy/smithy-client": "^4.9.8",
91
+ "@smithy/smithy-client": "^4.9.10",
92
92
  "@smithy/types": "^4.9.0",
93
93
  "@smithy/util-base64": "^4.3.0",
94
94
  "@smithy/util-middleware": "^4.2.5",