Skip to content

Commit 372b46f

Browse files
authored
fix(config-resolver): allow asterisk region with warning (#1760)
1 parent 4405450 commit 372b46f

File tree

7 files changed

+25
-6
lines changed

7 files changed

+25
-6
lines changed

.changeset/thick-mirrors-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/config-resolver": patch
3+
---
4+
5+
allow \* region with warning

packages/config-resolver/src/regionConfig/checkRegion.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("checkRegion", () => {
3939
"%",
4040
"^",
4141
"&",
42-
"*",
42+
"**",
4343
"(",
4444
")",
4545
".",
@@ -59,7 +59,14 @@ describe("checkRegion", () => {
5959
}
6060
});
6161

62+
it("emits a warning when asterisk region is used", () => {
63+
vi.spyOn(console, "warn");
64+
checkRegion("*");
65+
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("@smithy/config-resolver WARN"));
66+
});
67+
6268
it("caches accepted regions", () => {
69+
vi.spyOn(console, "warn");
6370
const di = {
6471
isValidHostLabel,
6572
};
@@ -73,5 +80,6 @@ describe("checkRegion", () => {
7380
expect(di.isValidHostLabel).toHaveBeenCalledTimes(0);
7481
expect(() => checkRegion("oh-canada", di.isValidHostLabel)).not.toThrow();
7582
expect(di.isValidHostLabel).toHaveBeenCalledTimes(1);
83+
expect(console.warn).not.toHaveBeenCalled();
7684
});
7785
});

packages/config-resolver/src/regionConfig/checkRegion.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ const validRegions = new Set<string>();
1515
*/
1616
export const checkRegion = (region: string, check = isValidHostLabel) => {
1717
if (!validRegions.has(region) && !check(region)) {
18-
throw new Error(`Region not accepted: region="${region}" is not a valid hostname component.`);
18+
if (region === "*") {
19+
console.warn(
20+
`@smithy/config-resolver WARN - Please use the caller region instead of "*". See "sigv4a" in https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/CLIENTS.md.`
21+
);
22+
} else {
23+
throw new Error(`Region not accepted: region="${region}" is not a valid hostname component.`);
24+
}
1925
} else {
2026
validRegions.add(region);
2127
}

private/my-local-model/src/auth/httpAuthSchemeProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const defaultXYZServiceHttpAuthSchemeProvider: XYZServiceHttpAuthSchemePr
6565
};
6666

6767
/**
68-
* @internal
68+
* @public
6969
*/
7070
export interface HttpAuthSchemeInputConfig {
7171
/**

private/smithy-rpcv2-cbor-schema/src/auth/httpAuthSchemeProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const defaultRpcV2ProtocolHttpAuthSchemeProvider: RpcV2ProtocolHttpAuthSc
6666
};
6767

6868
/**
69-
* @internal
69+
* @public
7070
*/
7171
export interface HttpAuthSchemeInputConfig {
7272
/**

private/smithy-rpcv2-cbor/src/auth/httpAuthSchemeProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const defaultRpcV2ProtocolHttpAuthSchemeProvider: RpcV2ProtocolHttpAuthSc
6666
};
6767

6868
/**
69-
* @internal
69+
* @public
7070
*/
7171
export interface HttpAuthSchemeInputConfig {
7272
/**

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/AddHttpAuthSchemePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private void generateHttpAuthSchemeInputConfigInterface(
222222
s.getResolveConfigFunctions();
223223
String serviceName = CodegenUtils.getServiceName(
224224
s.getSettings(), s.getModel(), s.getSymbolProvider());
225-
w.writeDocs("@internal");
225+
w.writeDocs("@public");
226226
w.writeInline("export interface HttpAuthSchemeInputConfig");
227227
if (!resolveConfigFunctions.isEmpty()) {
228228
w.writeInline(" extends ");

0 commit comments

Comments
 (0)