-
Notifications
You must be signed in to change notification settings - Fork 58
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 on scheduled/event-triggered functions with custom route #5344
Conversation
Turning to draft to write some tests. @eduardoboucas let me know if you think this should live in ZISI instead. |
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.
Nice! I think it makes sense for this to live in Netlify Build, since ZISI doesn't typically show any messaging. I just wonder what'll happen when running in Netlify Dev, since we won't go through build?
Perhaps we can add an additional check in the CLI, that doesn't throw an error and stop everything in its tracks, but instead shows a warning to tell people that this will be an issue when deploying?
|
||
if (schedule) { | ||
const error = new Error( | ||
`Scheduled functions must not specify a custom route. Please remove the "routes" configuration or pick a different name for the function. Learn more about scheduled functions at https://docs.netlify.com/functions/scheduled-functions.`, |
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.
routes
is not a public-facing property. Did you mean path
?
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.
yes, good catch! updated.
|
||
if (schedule) { | ||
const error = new Error( | ||
`Scheduled functions must not specify a custom route. Please remove the "routes" configuration or pick a different name for the function. Learn more about scheduled functions at https://docs.netlify.com/functions/scheduled-functions.`, |
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.
nit: I would use a ntl.fyi
short link here. It's more consistent with with other messaging and lets us point it to somewhere else if needed.
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.
good idea, done in 9fd107b
This pull request adds or modifies JavaScript ( |
|
||
if (schedule) { | ||
const error = new Error( | ||
`Scheduled functions must not specify a custom path. Please remove the "path" configuration or pick a different name for the function. Learn more about scheduled functions at https://ntl.fyi/custom-path-scheduled-functions.`, |
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.
Hmm how will picking a different name for the function help in the case of a scheduled function?
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.
copy & paste error!
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.
fixed in 4a5a13b
We could do that, but it's not super obvious where that'd live. Would we log an error during |
…nto detect-invalid-functions
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.
Nice!
Co-authored-by: Eduardo Bouças <[email protected]>
Closes https://linear.app/netlify/issue/COM-48/error-when-v2-function-define-custom-paths-for-scheduled-functions.
This PR adds detection for scheduled/event-triggered functions that define a custom route. We're throwing an error, because changing the route will break them being triggered correctly - plus, they're not publically callable anyways, so there's no reason to change their route.