Skip to content

Commit 8d1a35c

Browse files
committed
fix(client-s3): defer endpoint validations to ruleset
1 parent 2e76c7e commit 8d1a35c

File tree

12 files changed

+86
-62
lines changed

12 files changed

+86
-62
lines changed

clients/client-s3/src/S3Client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ export class S3Client extends __Client<
829829
const _config_0 = __getRuntimeConfig(configuration || {});
830830
super(_config_0 as any);
831831
this.initConfig = _config_0;
832+
type x = (typeof _config_0)["useArnRegion"];
832833
const _config_1 = resolveClientEndpointParameters(_config_0);
833834
const _config_2 = resolveUserAgentConfig(_config_1);
834835
const _config_3 = resolveFlexibleChecksumsConfig(_config_2);

clients/client-s3/src/models/models_0.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// smithy-typescript generated code
22
import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client";
3-
43
import { StreamingBlobTypes } from "@smithy/types";
54

65
import { S3ServiceException as __BaseException } from "./S3ServiceException";

clients/client-s3/src/models/models_1.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// smithy-typescript generated code
22
import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@smithy/smithy-client";
3-
43
import { StreamingBlobTypes } from "@smithy/types";
54

65
import {
@@ -41,7 +40,6 @@ import {
4140
Tag,
4241
TransitionDefaultMinimumObjectSize,
4342
} from "./models_0";
44-
4543
import { S3ServiceException as __BaseException } from "./S3ServiceException";
4644

4745
/**

clients/client-s3/src/protocols/Aws_restXml.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
import { loadRestXmlErrorCode, parseXmlBody as parseBody, parseXmlErrorBody as parseErrorBody } from "@aws-sdk/core";
33
import { XmlNode as __XmlNode, XmlText as __XmlText } from "@aws-sdk/xml-builder";
44
import { requestBuilder as rb } from "@smithy/core";
5-
import {
6-
HttpRequest as __HttpRequest,
7-
HttpResponse as __HttpResponse,
8-
isValidHostname as __isValidHostname,
9-
} from "@smithy/protocol-http";
5+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
106
import {
117
collectBody,
128
dateToUtcString as __dateToUtcString,
@@ -3215,18 +3211,6 @@ export const se_WriteGetObjectResponseCommand = async (
32153211
contents = input.Body;
32163212
body = contents;
32173213
}
3218-
let { hostname: resolvedHostname } = await context.endpoint();
3219-
if (context.disableHostPrefix !== true) {
3220-
resolvedHostname = "{RequestRoute}." + resolvedHostname;
3221-
if (input.RequestRoute === undefined) {
3222-
throw new Error("Empty value provided for input host prefix: RequestRoute.");
3223-
}
3224-
resolvedHostname = resolvedHostname.replace("{RequestRoute}", input.RequestRoute!);
3225-
if (!__isValidHostname(resolvedHostname)) {
3226-
throw new Error("ValidationError: prefixed hostname must be hostname compatible.");
3227-
}
3228-
}
3229-
b.hn(resolvedHostname);
32303214
b.m("POST").h(headers).b(body);
32313215
return b.build();
32323216
};

clients/client-s3/src/runtimeConfig.shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const getRuntimeConfig = (config: S3ClientConfig) => {
4343
signerConstructor: config?.signerConstructor ?? SignatureV4MultiRegion,
4444
signingEscapePath: config?.signingEscapePath ?? false,
4545
urlParser: config?.urlParser ?? parseUrl,
46-
useArnRegion: config?.useArnRegion ?? false,
46+
useArnRegion: config?.useArnRegion ?? (undefined as unknown as boolean),
4747
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
4848
utf8Encoder: config?.utf8Encoder ?? toUtf8,
4949
};

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public Model preprocessModel(Model model, TypeScriptSettings settings) {
224224

225225
Model builtModel = modelBuilder.addShapes(inputShapes).build();
226226
if (hasRuleset) {
227-
ModelTransformer.create().mapShapes(
227+
return ModelTransformer.create().mapShapes(
228228
builtModel, AddS3Config::removeHostPrefixTrait
229229
);
230230
}
@@ -246,7 +246,7 @@ public void addConfigInterfaceFields(
246246
.write("signingEscapePath?: boolean;\n");
247247
writer.writeDocs(
248248
"Whether to override the request region with the region inferred from requested resource's ARN."
249-
+ " Defaults to false.")
249+
+ " Defaults to undefined.")
250250
.addImport("Provider", "Provider", TypeScriptDependency.SMITHY_TYPES)
251251
.write("useArnRegion?: boolean | Provider<boolean>;");
252252
}
@@ -266,7 +266,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
266266
writer.write("false");
267267
},
268268
"useArnRegion", writer -> {
269-
writer.write("false");
269+
writer.write("undefined as unknown as boolean");
270270
}
271271
);
272272
case NODE:

packages/middleware-bucket-endpoint/src/NodeUseArnRegionConfigOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const NODE_USE_ARN_REGION_INI_NAME = "s3_use_arn_region";
77
/**
88
* Config to load useArnRegion from environment variables and shared INI files
99
*
10-
* @api private
10+
* @internal
1111
*/
1212
export const NODE_USE_ARN_REGION_CONFIG_OPTIONS: LoadedConfigSelectors<boolean> = {
1313
environmentVariableSelector: (env: NodeJS.ProcessEnv) =>
1414
booleanSelector(env, NODE_USE_ARN_REGION_ENV_NAME, SelectorType.ENV),
1515
configFileSelector: (profile) => booleanSelector(profile, NODE_USE_ARN_REGION_INI_NAME, SelectorType.CONFIG),
16-
default: false,
16+
default: undefined as unknown as boolean,
1717
};

packages/middleware-bucket-endpoint/src/bucketHostnameUtils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ export const validateRegion = (
131131
}
132132
if (options.useFipsEndpoint) {
133133
if (!options.allowFipsRegion) {
134-
throw new Error("FIPS region is not supported");
134+
// throw new Error("FIPS region is not supported");
135135
} else if (!isEqualRegions(region, options.clientRegion)) {
136-
throw new Error(`Client FIPS region ${options.clientRegion} doesn't match region ${region} in ARN`);
136+
// throw new Error(`Client FIPS region ${options.clientRegion} doesn't match region ${region} in ARN`);
137137
}
138138
}
139139
if (
140140
!options.useArnRegion &&
141141
!isEqualRegions(region, options.clientRegion || "") &&
142142
!isEqualRegions(region, options.clientSigningRegion || "")
143143
) {
144-
throw new Error(`Region in ARN is incompatible, got ${region} but expected ${options.clientRegion}`);
144+
// throw new Error(`Region in ARN is incompatible, got ${region} but expected ${options.clientRegion}`);
145145
}
146146
};
147147

@@ -235,8 +235,9 @@ export const getArnResources = (
235235
* @internal
236236
*/
237237
export const validateNoDualstack = (dualstackEndpoint?: boolean) => {
238-
if (dualstackEndpoint)
239-
throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
238+
if (dualstackEndpoint) {
239+
// throw new Error("Dualstack endpoint is not supported with Outpost or Multi-region Access Point ARN.");
240+
}
240241
};
241242

242243
/**

packages/middleware-bucket-endpoint/src/configurations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function resolveBucketEndpointConfig<T>(
9090
bucketEndpoint = false,
9191
forcePathStyle = false,
9292
useAccelerateEndpoint = false,
93-
useArnRegion = false,
93+
useArnRegion = undefined as unknown as boolean,
9494
disableMultiregionAccessPoints = false,
9595
} = input;
9696
return Object.assign(input, {

packages/middleware-sdk-s3-control/src/configurations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface S3ControlResolvedConfig {
5151
export function resolveS3ControlConfig<T>(
5252
input: T & PreviouslyResolved & S3ControlInputConfig
5353
): T & S3ControlResolvedConfig {
54-
const { useArnRegion = false } = input;
54+
const { useArnRegion = undefined as unknown as boolean } = input;
5555
return Object.assign(input, {
5656
useArnRegion: typeof useArnRegion === "function" ? useArnRegion : () => Promise.resolve(useArnRegion),
5757
});

0 commit comments

Comments
 (0)