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: error in transformers if override has never been setup #1270

Merged
merged 5 commits into from
Feb 21, 2023

Conversation

sobolk
Copy link
Member

@sobolk sobolk commented Feb 18, 2023

Description of changes

Fixes error that happens on pull.
image

This was introduced by not swallowing error in previous change. However this scenario has been missed.

Main vs CDKv2 branch:
image

CDK / CloudFormation Parameters Changed

Issue #, if available

Description of how you validated changes

E2E run with this PR + version bump https://app.circleci.com/pipelines/github/aws-amplify/amplify-category-api/4417/workflows/e2970acc-4cd8-4a9b-ad69-94eaca6ad167 .
The failing client_e2e_tests also fail on main due to 3rd party libraries dependency problem.

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Any CDK or CloudFormation parameter changes are called out explicitly

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sobolk sobolk requested a review from a team as a code owner February 18, 2023 01:56
Comment on lines 311 to 312
const overrideFilePath = path.join(this.overrideConfig!.overrideDir, 'build', 'override.js');
if (!_.isEmpty(this.overrideConfig) && this.overrideConfig!.overrideFlag && fs.existsSync(overrideFilePath)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The fix is in this file. I.e. there's added check if override file exists and condition is pulled to the top of method to spare some useless computing.

}
return appsyncResourceObj;

return {};
Copy link
Member Author

Choose a reason for hiding this comment

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

if there's no override file or override has not been requested by caller returning {} is consistent with behavior on main branch.

@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2023

Codecov Report

Merging #1270 (6d56b24) into cdkv2 (88016c3) will increase coverage by 0.00%.
The diff coverage is 36.20%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##            cdkv2    #1270   +/-   ##
=======================================
  Coverage   63.56%   63.57%           
=======================================
  Files         302      302           
  Lines       18993    19005   +12     
  Branches     4569     4568    -1     
=======================================
+ Hits        12073    12082    +9     
- Misses       6289     6292    +3     
  Partials      631      631           
Impacted Files Coverage Δ
...l-transformer-core/src/transformation/transform.ts 15.48% <0.00%> (-0.09%) ⬇️
...ansformer-core/src/transformer-context/resolver.ts 5.58% <0.00%> (-0.03%) ⬇️
...ql-auth-transformer/src/resolvers/subscriptions.ts 100.00% <100.00%> (ø)
...ema-transformer/src/RelationalDBMappingTemplate.ts 100.00% <100.00%> (ø)
...a-transformer/src/RelationalDBResolverGenerator.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sobolk
Copy link
Member Author

sobolk commented Feb 19, 2023

E2E run with this PR + version bump https://app.circleci.com/pipelines/github/aws-amplify/amplify-category-api/4417/workflows/e2970acc-4cd8-4a9b-ad69-94eaca6ad167 .
The failing client_e2e_tests also fail on main due to 3rd party libraries dependency problem.

@sobolk sobolk changed the title fix: error in transformers if override is missing fix: error in transformers if override has never been setup Feb 20, 2023
jhockett
jhockett previously approved these changes Feb 20, 2023
Copy link
Contributor

@phani-srikar phani-srikar left a comment

Choose a reason for hiding this comment

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

Do we need this change in the main as well?

stacks.push(node.node.id.split('.')[0]);
}
});
const overrideFilePath = path.join(this.overrideConfig!.overrideDir, 'build', 'override.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

we're checking !_.isEmpty(this.overrideConfig) in the below line, but I am afraid this.overrideConfig!.overrideDir will throw if that's the case here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@phani-srikar thanks for spotting this. It was working e2e because callers have redundant check.
I refactored those conditionals a bit to simplify the flow. I.e. now non-empty check is bundled with overrideFlag check through ? operator.
I also inverted logic to shortcircuit this method.

@sobolk
Copy link
Member Author

sobolk commented Feb 21, 2023

Do we need this change in the main as well?

No. main is swallowing this error, see screenshot under "Main vs CDKv2 branch" in PR description.
There was an intentional change on cdkv2 branch to bubble up override errors.

@sobolk sobolk merged commit bba14c3 into aws-amplify:cdkv2 Feb 21, 2023
@sobolk sobolk deleted the fix-override-error-in-transformers branch February 21, 2023 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants