@@ -136,23 +136,34 @@ def check_command_property(command):
136
136
w.r.t. individual commands.
137
137
:param command: command element
138
138
"""
139
-
140
139
if not isinstance (command , dict ):
141
140
raise CommandConfigurationException ("command '{}' is not a dictionary" .format (command ))
142
141
143
- command_value = command .get (COMMAND_PROPERTY )
144
- call_value = command .get (CALL_PROPERTY )
145
- if command_value is None and call_value is None :
146
- raise CommandConfigurationException (f"command dictionary has unknown key: { command } " )
142
+ for key in command .keys ():
143
+ if key not in [COMMAND_PROPERTY , CALL_PROPERTY ]:
144
+ raise CommandConfigurationException (f"command dictionary has unknown key: { command } " )
147
145
148
- if command_value and not isinstance (command_value , dict ):
149
- raise CommandConfigurationException ("command value not a dictionary: {}" .
150
- format (command_value ))
151
- if call_value :
152
- check_call_config (call_value )
146
+ # There is difference between dictionary key that is missing and dictionary key that has None value.
147
+ # The get() function cannot distinguish between these two. Given the latter is sometimes a result
148
+ # of YAML parsing, use the below code to catch it.
149
+ try :
150
+ command_value = command [COMMAND_PROPERTY ]
151
+ if command_value is None :
152
+ raise CommandConfigurationException ("empty command value" )
153
153
154
- if command_value :
155
154
check_command_config (command_value )
155
+ return
156
+ except KeyError :
157
+ pass
158
+
159
+ try :
160
+ call_value = command [CALL_PROPERTY ]
161
+ if call_value is None :
162
+ raise CommandConfigurationException ("empty call value" )
163
+
164
+ check_call_config (call_value )
165
+ except KeyError :
166
+ pass
156
167
157
168
158
169
class ApiCall :
0 commit comments