Skip to content

Commit 7d90b33

Browse files
committed
fix(core/protocols): awsQuery error shape consistency and ec2 middleware content length
1 parent 03cd619 commit 7d90b33

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ export class AwsQueryProtocol extends RpcProtocol {
144144
const errorData = this.loadQueryError(dataObject);
145145
const message = this.loadQueryErrorMessage(dataObject);
146146
errorData.message = message;
147+
errorData.Error = {
148+
Type: errorData.Type,
149+
Code: errorData.Code,
150+
Message: message,
151+
};
147152

148153
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(
149154
errorIdentifier,
@@ -160,7 +165,9 @@ export class AwsQueryProtocol extends RpcProtocol {
160165
const ns = NormalizedSchema.of(errorSchema);
161166
const exception = new errorSchema.ctor(message);
162167

163-
const output = {} as any;
168+
const output = {
169+
Error: errorData.Error,
170+
} as any;
164171

165172
for (const [name, member] of ns.structIterator()) {
166173
const target = member.getMergedTraits().xmlName ?? name;

packages/middleware-sdk-ec2/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { getEndpointFromInstructions, toEndpointV1 } from "@smithy/middleware-en
33
import { HttpRequest } from "@smithy/protocol-http";
44
import { SignatureV4 } from "@smithy/signature-v4";
55
import { extendedEncodeURIComponent } from "@smithy/smithy-client";
6-
import {
6+
import type {
77
AwsCredentialIdentity,
8+
BodyLengthCalculator,
89
ChecksumConstructor,
910
Endpoint,
1011
HandlerExecutionContext,
@@ -29,6 +30,7 @@ interface PreviouslyResolved {
2930
sha256: ChecksumConstructor | HashConstructor;
3031
signingEscapePath: boolean;
3132
regionInfoProvider?: RegionInfoProvider;
33+
bodyLengthChecker: BodyLengthCalculator;
3234
}
3335

3436
const version = "2016-11-15";
@@ -113,8 +115,8 @@ export function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved):
113115
},
114116
};
115117

116-
// we also double-check the work of the serialzier here
117-
// because this middleware may be placed after the regular serialzier.
118+
// we also double-check the work of the serializer here
119+
// because this middleware may be placed after the regular serializer.
118120
if (HttpRequest.isInstance(args.request)) {
119121
const { request } = args;
120122
if (!(request.body ?? "").includes("DestinationRegion=")) {
@@ -123,6 +125,9 @@ export function copySnapshotPresignedUrlMiddleware(options: PreviouslyResolved):
123125
if (!(request.body ?? "").includes("PresignedUrl=")) {
124126
request.body += `&PresignedUrl=${extendedEncodeURIComponent(args.input.PresignedUrl)}`;
125127
}
128+
if (typeof options.bodyLengthChecker === "function") {
129+
request.headers["content-length"] = String(options.bodyLengthChecker(request.body));
130+
}
126131
}
127132
}
128133

0 commit comments

Comments
 (0)