-
Notifications
You must be signed in to change notification settings - Fork 166
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
Reject unrecognized options in config objects (but still allow it at the top-level) #623
Changes from all commits
94cc1e8
877998b
7051bca
063593f
6e682df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -537,6 +537,20 @@ def test_raise_construct_error_on_duplicate_stack_name_dict(self): | |
with self.assertRaises(ConstructorError): | ||
parse(yaml_config) | ||
|
||
def test_parse_invalid_inner_keys(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks! |
||
yaml_config = """ | ||
namespace: prod | ||
stacks: | ||
- name: vpc | ||
class_path: blueprints.VPC | ||
garbage: yes | ||
variables: | ||
Foo: bar | ||
""" | ||
|
||
with self.assertRaises(exceptions.InvalidConfig): | ||
parse(yaml_config) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.