Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: overwrite clients in protocol clients #1283

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Jun 18, 2020

Issue #, if available:
Came across this bug while working on codegen to introduce retry-config-provider from #1282 in runtimeConfig

Description of changes:
overwrite clients in protocol clients

The clients in protocol clients are not overwritten because they are prefixed with aws- and not client-

Code
const isPathnameClientInPackageName = (pathName, packageName) =>
  pathName
    .toLowerCase()
    .indexOf(
      packageName
        .toLowerCase()
        .replace("@aws-sdk/client-", "")
        .replace(/-/g, "")
    ) >= 0;

// logs true
console.log(isPathnameClientInPackageName("S3.ts", "@aws-sdk/client-s3"));
console.log(isPathnameClientInPackageName("S3Client.ts", "@aws-sdk/client-s3"));

// logs false
console.log(
  isPathnameClientInPackageName("JsonProtocol.ts", "@aws-sdk/aws-json")
);
console.log(
  isPathnameClientInPackageName("JsonProtocolClient.ts", "@aws-sdk/aws-json")
);

It's fixed by checking for aws- prefix.

Code
const isPathnameClientInPackageName = (pathName, packageName) =>
  pathName
    .toLowerCase()
    .startsWith(
      packageName
        .toLowerCase()
        .replace("@aws-sdk/client-", "")
        .replace("@aws-sdk/aws-", "")
        .replace(/-/g, "")
    );

// logs true
console.log(isPathnameClientInPackageName("S3.ts", "@aws-sdk/client-s3"));
console.log(isPathnameClientInPackageName("S3Client.ts", "@aws-sdk/client-s3"));

// logs true
console.log(
  isPathnameClientInPackageName("JsonProtocol.ts", "@aws-sdk/aws-json")
);
console.log(
  isPathnameClientInPackageName("JsonProtocolClient.ts", "@aws-sdk/aws-json")
);

This PR also tests that pathName starts with the string (so that protocol names like "json" doesn't set extensions to true)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

Codecov Report

Merging #1283 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1283      +/-   ##
==========================================
+ Coverage   73.04%   73.06%   +0.01%     
==========================================
  Files         287      287              
  Lines       12730    12736       +6     
  Branches     2922     2924       +2     
==========================================
+ Hits         9299     9305       +6     
  Misses       3431     3431              
Impacted Files Coverage Δ
packages/middleware-retry/src/defaultStrategy.ts 100.00% <100.00%> (ø)
packages/region-provider/src/defaultProvider.ts 100.00% <100.00%> (ø)
packages/region-provider/src/fromEnv.ts 100.00% <100.00%> (ø)
...kages/region-provider/src/fromSharedConfigFiles.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f61141...96afc21. Read the comment docs.

@trivikr trivikr requested a review from alexforsyth June 18, 2020 16:31
Copy link
Contributor

@alexforsyth alexforsyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@trivikr trivikr merged commit 83c419e into aws:master Jun 18, 2020
@trivikr trivikr deleted the fix-overwrite-protocol-client branch June 18, 2020 16:57
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants