From e23253815c957b8c503494ab4124ae051df4a55b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 24 Jan 2019 11:07:58 -0500 Subject: [PATCH] Fix checking code with custom fields For custom fields, do not cause an unexpected errors. The lookup on the validattrs will now default to nothing found instead of error. --- confluent_server/confluent/messages.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index f0265329..0ffca828 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -613,12 +613,12 @@ class InputAttributes(ConfluentMessage): # an expression string will error if format() done # use that as cue to put it into config as an expr nodeattr[attr] = {'expression': nodeattr[attr]} - if validattrs and 'validvalues' in validattrs[attr]: + if validattrs and 'validvalues' in validattrs.get(attr, []): if nodeattr[attr] not in validattrs[attr]['validvalues']: raise exc.InvalidArgumentException( 'Attribute {0} does not accept value {1} (valid values would be {2})'.format( attr, nodeattr[attr], ','.join(validattrs[attr]['validvalues']))) - elif validattrs and 'validlist' in validattrs[attr]: + elif validattrs and 'validlist' in validattrs.get(attr, []): req = nodeattr[attr].split(',') for v in req: if v not in validattrs[attr]['validlist']: @@ -627,7 +627,7 @@ class InputAttributes(ConfluentMessage): '{1} (valid values would be {2})'.format( attr, v, ','.join( validattrs[attr]['validlist']))) - elif validattrs and 'validlistkeys' in validattrs[attr]: + elif validattrs and 'validlistkeys' in validattrs.get(attr, []): req = nodeattr[attr].split(',') for v in req: if '=' not in v: