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 schema validation of CloudFront distribution config #8308

Merged
merged 3 commits into from Oct 1, 2020

Conversation

jede
Copy link
Contributor

@jede jede commented Sep 30, 2020

Addresses: #8025 (this is a minor bugfix related to PR #8250)

I noticed some unsupported configuration format warnings that occurred after #8250 with CloudFront events and specifically using AllowedMethods, CachedMethods and ForwardedValues:

So I used the example given here to write a test that validates the config.

Any feedback is welcome!

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2020

Codecov Report

Merging #8308 into master will decrease coverage by 0.14%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8308      +/-   ##
==========================================
- Coverage   88.16%   88.02%   -0.15%     
==========================================
  Files         250      249       -1     
  Lines        9391     9312      -79     
==========================================
- Hits         8280     8197      -83     
- Misses       1111     1115       +4     
Impacted Files Coverage Δ
...ins/aws/package/compile/events/cloudFront/index.js 99.32% <ø> (ø)
...ins/aws/package/compile/events/alb/lib/validate.js 95.31% <0.00%> (-2.52%) ⬇️
lib/plugins/aws/invokeLocal/index.js 68.53% <0.00%> (-1.13%) ⬇️
...ib/plugins/aws/package/lib/generateCoreTemplate.js 95.12% <0.00%> (-0.34%) ⬇️
lib/plugins/aws/provider/awsProvider.js 93.04% <0.00%> (-0.15%) ⬇️
.../compile/events/apiGateway/lib/hack/updateStage.js 95.06% <0.00%> (-0.09%) ⬇️
lib/plugins/aws/package/lib/mergeIamTemplates.js 100.00% <0.00%> (ø)
...ib/plugins/aws/package/compile/events/alb/index.js 100.00% <0.00%> (ø)
...ib/plugins/aws/package/compile/events/sqs/index.js 100.00% <0.00%> (ø)
lib/plugins/aws/lib/validateS3BucketName.js

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 e990c09...1d058b2. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@jede great thanks for that! Indeed, there's an issue, and I have no idea how it got in, in this form.

Still, please see my comment, I think we can have it way simpler

lib/plugins/aws/package/compile/events/cloudFront/index.js Outdated Show resolved Hide resolved
@jede
Copy link
Contributor Author

jede commented Sep 30, 2020

I made the changes you suggested, but let me know if the order thing matters, in that case I can just revert :)

@jede jede requested a review from medikoo September 30, 2020 13:12
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@jede sorry for confusion, but after your input, it's clear that what you proposed originally while more verbose, is definitely more correct.

@jede jede force-pushed the aws-cloudfront-event-schema-fixes branch from 4008c6c to 8e65905 Compare September 30, 2020 13:21
@jede
Copy link
Contributor Author

jede commented Sep 30, 2020

No worries! I reset it back to the original. Happy to contribute!

@jede jede requested a review from medikoo September 30, 2020 13:27
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@jede great thanks for update. It all looks good for AllowedMethods and CachedMethods but I've discovered some issues with ForwardedValues please see my comments

lib/plugins/aws/package/compile/events/cloudFront/index.js Outdated Show resolved Hide resolved
@jede
Copy link
Contributor Author

jede commented Sep 30, 2020

Great! Fixed it and adjusted the test case.

@jede jede requested a review from medikoo September 30, 2020 14:30
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Thanks for comment @jede, as we discussed, it seems reasonable to recognize ForwardedValues.

Now when reviewing deeply it's schema, I've spotted few schema issues, and proposed one style improvement. Let me know

@jede
Copy link
Contributor Author

jede commented Oct 1, 2020

Thanks for the suggestions! Makes it more coherent with the rest of the code. I went ahead and added type: 'array' for the values in AllowedMethods and CachedMethods as well.

@jede jede requested a review from medikoo October 1, 2020 08:49
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Thank you @jede, that looks great!

@medikoo medikoo merged commit 5b740f6 into serverless:master Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants