diff --git a/stackdistiller/distiller.py b/stackdistiller/distiller.py index d834ef0..b8b6c20 100644 --- a/stackdistiller/distiller.py +++ b/stackdistiller/distiller.py @@ -105,7 +105,13 @@ class TraitDefinition(object): self.cfg = trait_cfg self.name = name - type_name = trait_cfg.get('type', 'text') + type_name = None + try: + type_name = trait_cfg.get('type', 'text') + except AttributeError as e: + raise EventDefinitionException( + "Unable to get type for '%s'" % trait_cfg, + self.cfg) if 'plugin' in trait_cfg: plugin_cfg = trait_cfg['plugin'] diff --git a/tests/test_distiller.py b/tests/test_distiller.py index 66d6729..64fd87d 100644 --- a/tests/test_distiller.py +++ b/tests/test_distiller.py @@ -143,6 +143,13 @@ class TestTraitDefinition(DistillerTestBase): self.fake_plugin_map = dict(test=self.test_plugin_class, nothing=self.nothing_plugin_class) + def test_bad_field_definition(self): + self.assertRaises(distiller.EventDefinitionException, + distiller.TraitDefinition, + 'test_trait', + "foo", + self.fake_plugin_map) + def test_to_trait_with_plugin(self): cfg = dict(type='text', fields=['payload.instance_id', 'payload.instance_uuid'],