From 9e467c5e57b69f31a420c1f3a29fabc7c19c4199 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 26 Jan 2018 17:00:03 -0500 Subject: [PATCH] Add check for invalid dotted attribute names in expressions This provides better feedback for typos and mistakes. --- confluent_server/confluent/config/configmanager.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index f5c96cbc..ea952f38 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -424,6 +424,10 @@ class _ExpressionFormat(string.Formatter): key = '.' + left.attr + key left = left.value key = left.id + key + if (not key.startswith('custom.') and + _get_valid_attrname(key) not in allattributes.node): + raise ValueError( + '{0} is not a valid attribute name'.format(key)) val = self._expand_attribute(key) return val['value'] if val and 'value' in val else "" elif isinstance(node, ast.Name):