-
Notifications
You must be signed in to change notification settings - Fork 175
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: do validation for params off constructor so it can throw before starting #1984
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.
👍
const reservedParams = Object.keys(options.params).filter( | ||
(key) => RESERVED_PARAMS.has(key) | ||
) | ||
if (reservedParams.length > 0) { | ||
throw new Error( | ||
`Cannot use reserved Electric parameter names in custom params: ${reservedParams.join(`, `)}` | ||
) | ||
} |
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: this could be simpler?
for (const param of RESERVED_PARAMS) {
if (param in options.params) {
throw new Error(`Cannot use reserved Electric parameter name in custom params: ${param}`);
}
}
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 existing test checks all parameters before throwing an error — so the error message is more comprehensive than if you throw immediately.
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
did this wrong in #1978 so that combined with #1983, passing a reserved parameter just means it silently fails atm.