Skip to content

Commit 3ecb1f4

Browse files
authored
fix(middleware-endpoint): return undefined for endpointParam=endpoint when isCustomEndpoint is false (#1643)
1 parent e051a08 commit 3ecb1f4

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

.changeset/sharp-ducks-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/middleware-endpoint": patch
3+
---
4+
5+
return undefined for endpointParam "endpoint" if isCustomEndpoint is false

packages/middleware-endpoint/src/adaptors/createConfigValueProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export const createConfigValueProvider = <Config extends Record<string, unknown>
4242

4343
if (configKey === "endpoint" || canonicalEndpointParamKey === "endpoint") {
4444
return async () => {
45+
if (config.isCustomEndpoint === false) {
46+
return undefined;
47+
}
4548
const endpoint = await configProvider();
4649
if (endpoint && typeof endpoint === "object") {
4750
if ("url" in endpoint) {

packages/middleware-endpoint/src/adaptors/getEndpointFromInstructions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const getEndpointFromInstructions = async <
3838
clientConfig: Partial<EndpointResolvedConfig<T>> & Config,
3939
context?: HandlerExecutionContext
4040
): Promise<EndpointV2> => {
41-
if (!clientConfig.endpoint) {
41+
if (!clientConfig.isCustomEndpoint) {
4242
let endpointFromConfig: string | undefined;
4343

4444
// This field is guaranteed by the type indicated by the config resolver, but is new

packages/middleware-endpoint/src/endpointMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const endpointMiddleware = <T extends EndpointParameters>({
3939
context: HandlerExecutionContext
4040
): SerializeHandler<any, Output> =>
4141
async (args: SerializeHandlerArguments<any>): Promise<SerializeHandlerOutput<Output>> => {
42-
if (config.endpoint) {
42+
if (config.isCustomEndpoint) {
4343
setFeature(context, "ENDPOINT_OVERRIDE", "N");
4444
}
4545

packages/middleware-endpoint/src/resolveEndpointConfig.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ interface PreviouslyResolved<T extends EndpointParameters = EndpointParameters>
6464
/**
6565
* @internal
6666
*
67-
* This supercedes the similarly named EndpointsResolvedConfig (no parametric types)
67+
* This supersedes the similarly named EndpointsResolvedConfig (no parametric types)
6868
* from resolveEndpointsConfig.ts in \@smithy/config-resolver.
6969
*/
7070
export interface EndpointResolvedConfig<T extends EndpointParameters = EndpointParameters> {
@@ -85,8 +85,11 @@ export interface EndpointResolvedConfig<T extends EndpointParameters = EndpointP
8585

8686
/**
8787
* Whether the endpoint is specified by caller.
88+
* This should be used over checking the existence of `endpoint`, since
89+
* that may have been set by other means, such as the default regional
90+
* endpoint provider function.
91+
*
8892
* @internal
89-
* @deprecated
9093
*/
9194
isCustomEndpoint?: boolean;
9295

0 commit comments

Comments
 (0)