Reject unrecognized options in config objects (but still allow it at the top-level)#623
Conversation
Validation already caught them, but parsing needs to do it too.
phobologic
left a comment
There was a problem hiding this comment.
Mostly some questions, and possibly could use another test (though may be already covered, let me know). Thanks!
| try: | ||
| return Config(config_dict, strict=True) | ||
| except SchematicsError as e: | ||
| raise exceptions.InvalidConfig(e.errors) |
There was a problem hiding this comment.
I don't know the schematics Exceptions well enough - but will this provide enough data to figure out what the issue is? I really wish python2 provided a good way for wrapping exceptions.
There was a problem hiding this comment.
Yes, the only issue is the message is not very explanatory. e.errors is something like this when an invalid key is present: {"stacks": {"0": {"garbage": "Rogue field"}}}. But I think the best place to fix it is in Schematics itself.
| with self.assertRaises(ConstructorError): | ||
| parse(yaml_config) | ||
|
|
||
| def test_parse_invalid_inner_keys(self): |
There was a problem hiding this comment.
Do we already have a test that has excess keys at the top level that would cover that use case?
There was a problem hiding this comment.
test_parse_with_arbitrary_anchors seems to do the job: https://github.com/Cobliteam/stacker/blob/94cc1e8a4eea1eb7ee8329caa4b25a61cd98c648/stacker/tests/test_config.py#L168
|
Thanks @danielkza ! |
…the top-level) (cloudtools#623) * config: re-enable strict mode by manually removing excess top level keys * tests: fix typo in stack_policy_path in functional tests * config: ensure Schematics errors are converted during parsing Validation already caught them, but parsing needs to do it too. * Update changelog with strict parsing changes * tests: fix stack policy path (should be relative to the tests dir)
No description provided.