-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(synthetics): updated handler validation #26569
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
Exemption Request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on @lpizzinidev. One more thing: I think we should add a basic integ test that tests the folder/fileName.functionName
scenario with a recent runtime just to make sure that the docs aren't wrong :) because sometimes they are.
if (handler !== 'index.handler') { | ||
throw new Error(`The handler for inline code must be "index.handler" (got "${handler}")`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about removing this. Have you tested this to make sure that it works? IIRC lambda will bundle inline code into an index.js|py
file, which means that it should at least always start with index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restored the original code since I'm unsure about the expected behavior and couldn't find documentation about it.
Let me know if you think we should dive deeper into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see anyone complaining about this, and it looks right to me. So lets keep it for now
if ( | ||
runtime === Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0 || | ||
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_0 || | ||
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_1 || | ||
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2 || | ||
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3 | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( | |
runtime === Runtime.SYNTHETICS_PYTHON_SELENIUM_1_0 || | |
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_0 || | |
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_1 || | |
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2 || | |
runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3 | |
) { | |
const oldRuntimes = [/*put those runtimes here */]; | |
if (oldRuntimes.includes(runtime)) { |
} else if (runtime === Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_4) { | ||
if (!handler.match(/^[0-9A-Za-z_\\-]+\.[A-Za-z_][A-Za-z0-9_]*$/)) { | ||
throw new Error(`Canary Handler must be specified either as \'fileName.handler\' or \'fileName.functionName\' for the \'syn-nodejs-puppeteer-3.4'\ runtime, received ${handler}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where did you get the info that 3.4 has it's own specific rule? From the cfn docs it seems this isn't the case:
For syn-python-selenium-1.1, syn-nodejs.puppeteer-3.4, and later runtimes, the handler can be specified as fileName.functionName , or you can specify a folder where canary scripts reside as folder/fileName.functionName .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I think I misread this line.
I'll apply the suggested changes and add the required tests.
}).toThrow(/Canary Handler must be specified either as 'fileName.handler' or 'fileName.functionName' for the 'syn-nodejs-puppeteer-3.4' runtime/); | ||
}); | ||
|
||
testDeprecated('recent runtimes', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also unit test that fileName.functionName
and folder/fileName.functionName
passes the regex for recent runtimes
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
if (handler !== 'index.handler') { | ||
throw new Error(`The handler for inline code must be "index.handler" (got "${handler}")`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see anyone complaining about this, and it looks right to me. So lets keep it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lpizzinidev!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This fix updates handler validation based on Synthetic rules for Node and Python runtimes.
Closes #26540.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license