-
Notifications
You must be signed in to change notification settings - Fork 147
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
autoinstall: reject null values in autoinstall top level sections #1377
base: main
Are you sure you want to change the base?
Conversation
According to the autoinstall schema, the top level autoinstall sections (except proxy) should not accept null as a valid value. However, passing null in one of these section effectively bypasses the schema validation. The reason why we decided to skip validation when a section is null is to allow the autoinstall_default key of the controllers to be None. Having None as a default value is a perfectly sensible choice, but the logic is sort of wrong. Instead of skipping the validation when a section is resolved to None, we should instead skip validation if the section was not present. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Original comment from @dbungert: I think we should make the needed schema changes to allow foo: null for all toplevel keys except version. There is a small risk that someone has used that to explicitly say "give me the defaults for this section" rather than relying on obtaining that by omission, and proxy serves as a sort of precedent for that. If there are other cases like version where that doesn't make sense, let's discuss. |
Yes, I see your point but I don't think this is sane to let the users think they can pass For the following controllers, we set a custom value that gets used when said section is absent:
but if the section is set to def load_autoinstall_data(self, data):
log.debug("data is %s", data)
os.environ["LANG"] = data with no
with
(and also it fails later on):
I would prefer rejecting |
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 agree this behaviour is a wholly unintended consequence of the way the validation works and we should fix it. Is there any way we can test this sensibly?
Probably! Are you asking about an integration test that expects subiquity to reject Also, do you have an opinion on breaking backward compatibility for users that have potentially (ab)used this behavior to get the default on some of the sections? This is what @dbungert is concerned about. |
opening this PR to split the original #1375
When working on the above PR, I realized that the top level autoinstall sections accepted the
null
value although such a configuration should have been rejected according to the JSON schema:This happened because the JSON validation was skipped when a section was set to
null
. The goal was to allow the controllers to setautoinstall_default
toNone
(which is a sensible thing to do).However, instead of skipping validation when the section resolves to
None
, the better thing to do is to skip the validation whenautoinstall_default
is effectively used.If we want to accept
null
for a given section, we can by adding"null"
to the list of accepted types:the
proxy
section is an example.