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(config/validation): improve validation of global options #25218
fix(config/validation): improve validation of global options #25218
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.
Please expand the description as this is too generic/non-descriptive. What is this PR changing and why?
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
What is the expected difference before/after this PR? I just ran with an invalid option in config.js and did not get any warning or error |
The log:
My expectation was that the |
This is because we do not validate file config in repo runs. |
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.
we should get this done
This comment was marked as outdated.
This comment was marked as outdated.
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.
we should refactor validation to use same style as config migration for easier future additions and easier testing.
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.
Is this a feature or a fix? There's seems to have been some logic here already which is improved/fixed
Adding feat scope was a mistake. It should be the It does 2 jobs:
Basically we improve the validation, so a |
🎉 This PR is included in version 37.203.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Not to bump this, but this kinda broke stuff, and I'm not complete sure how to fix this. E.g.:
Taken the example from https://docs.renovatebot.com/examples/self-hosting/#usage even produces an error:
|
Not sure about the The |
hostRules: [
{
matchHost: "gitlab.<the rest>",
token: process.env.RENOVATE_TOKEN,
},
], That might however be my own error? 🤔 |
Is this from when you run it with the validator? |
Correct. And it has now broken the pipeline, meaning the template from GitLab won't run. |
I think I can reproduce one of these. If you have a config.js, and it has a host rules entry with token pointing to an env variable, and that env variable doesn't exist when you run the validator, then the token=undefined and the validator will error. If instead the env variable is defined/valid then you don't get an error. |
@MindTooth please create a new github discussion to continue this topic |
Do we need to fix the documentation or the code for the example:
|
|
Changes
Add validation for globalOptions.
This PR changes the behaviour of
config-validator
when in comes to validating the file config. Till now we couldn't validate the global options inside file config fully ... even after adding logic to warn for any global option in repo config. We used to getinvalid config option error
instead if a proper validation erro... This has been fixed and now we can valiate all the config options, based on their types, and allowedValues (where needed).I decided to create a new function to validate the global options even though it was possible to modify the existing function for our use case, because we want to warn for any validation errors and not throw errors. Since the existing function is designed mainly for errors adding warnings for the global options would've made it less redable and more nested.
Context
Needed For: #26379
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: