Skip to content

Commit e659a06

Browse files
authored
fix(core/schema): set explicit enumerability on error.$response (#1778)
1 parent 05b7e11 commit e659a06

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

.changeset/fifty-oranges-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/core": patch
3+
---
4+
5+
set explicit enumerability on error.$response

.changeset/fuzzy-goats-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/middleware-serde": patch
3+
---
4+
5+
explicit non-enumerability for error.$response

packages/core/src/submodules/cbor/SmithyRpcV2CborProtocol.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export class SmithyRpcV2CborProtocol extends RpcProtocol {
9999

100100
const errorMetadata = {
101101
$metadata: metadata,
102-
$response: response,
103102
$fault: response.statusCode <= 500 ? ("client" as const) : ("server" as const),
104103
};
105104

packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export const schemaDeserializationMiddleware =
4141
// For security reasons, the error response is not completely visible by default.
4242
Object.defineProperty(error, "$response", {
4343
value: response,
44+
// we need to define these properties explicitly because
45+
// the service exception class may have set the value to undefined, but populated the key.
46+
enumerable: false,
47+
writable: false,
48+
configurable: false,
4449
});
4550

4651
if (!("$metadata" in error)) {

packages/middleware-serde/src/deserializerMiddleware.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export const deserializerMiddleware =
4040
// For security reasons, the error response is not completely visible by default.
4141
Object.defineProperty(error, "$response", {
4242
value: response,
43+
// we need to define these properties explicitly because
44+
// the service exception class may have set the value to undefined, but populated the key.
45+
enumerable: false,
46+
writable: false,
47+
configurable: false,
4348
});
4449

4550
if (!("$metadata" in error)) {

0 commit comments

Comments
 (0)