-
Notifications
You must be signed in to change notification settings - Fork 11
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 ubi config validation doesn't really validate #30
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.
Could we please have some updates to testcases as well? That was just as big a problem here - that validation was effectively a no-op and yet no autotest failed. It really ought to be fixed as well.
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.
In the commit message, looks like " [fix #28 #29]" is not going to work to close both issues. The UI is indicating that it only close issue 28.
Could you please adjust it in some way so it closes both? I know in our internal projects we used [] in first line of commits, but I don't think it necessarily makes sense here, probably mentioning the two issues in two separate lines of the commit message body makes more sense.
I also think we shouldn't just crash when yaml file is invalid or has wrong syntax. Imho in case of invalid file, ubi-config should log error and skip current file from processing at least when we read all config files from remote repo. @JayZ12138 What do you think? try:
config_dict = yaml.safe_load(response.content)
except yaml.YAMLError:
LOG.error('There is syntax error in your config file %s, please fix', file_name)
>>> raise
else:
if self.local_repo:
file_path = os.path.join(self.local_repo, file_name)
else:
file_path = file_name
LOG.info("Loading configuration file locally: %s", file_path)
with open(file_path, 'r') as f:
config_dict = yaml.safe_load(f)
# validate input data
>>> validate_config(config_dict) |
Hmm, just feel [] makes it more clear. |
I was thinking about the test cases, but seems like there's no way to verify it really validate the incoming config. |
@rbikar But, yeah, from our point of view, it's suitable to do this change. I'll change it anyway. |
We had some invalid yaml files in one branch, now it's fixed. It had empty packages whitelist. |
ca19017
to
63e6c68
Compare
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 think tests should cover more possibilities of incorrect input.
@midnightercz |
6391887
to
bd1d4bf
Compare
I think this should be "at most", as it's unnecessarily more difficult to write correct code if Either way, it seems to be a separate issue from the validation not working. |
What I think is, if there's such error in config file, then we should file a ticket to the team who generated it and ask them to resolve this immediately. If we really want to continue the push, we can enter the config files one by one manually. I filed a separately issue already. |
|
||
|
||
def test_validate_failed_wrong_data_type(dnf7_config): | ||
dnf7_config['packages']['inlcude'] = 'A string' |
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 feel like this isn't testing what you wanted, since the test name says "wrong data type" but here you've got a typo 'inlcude'. Did you mean 'include' so that you'd test what happens if include is a string?
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.
yeah, it's a typo here..
I think for every key that is required to be in some form (value, type, non-empty) by schema. We should have following set of tests:
|
Previously, the keyword 'properities' was missing in the config schema, while the config schema itself was still valid, it wasn't really used to validate any incoming data. Fix release-engineering#29 Add 'packages' and 'content_sets' requirements to json schema, which would fail the validation if those two blocks of configuration are missing. Fix release-engineering#28 Set additionalProperites to False, so only the declared properities are allowed. Also, make module's stream allows both number and string
Hmm, I feel it's too complicated. |
But you don't prove tat keywords and types are working. I believe that's covered in unit tests in json-schema library. |
Previously, the keyword 'properities' was missing in the config schema,
while the config schema itself was still valid, it wasn't really used to
validate any incoming data. Fix #29
Add 'packages' and 'content_sets' requirements to json schema, which would
fail the validation if those two blocks of configuration are missing. Fix #28
Set additionalProperites to False, so only the declared properities
are allowed.
Also, make module's stream allows both number and string