Skip to content

Commit 9b2dd75

Browse files
author
David Noble
committed
DVPL-4301: Custom ReportingCommand crashes when it does not implement map operation
Fix: + Changed test for ReportingCommand.map override in ReportingCommand.ConfigurationSettings.fix_up Effect: We correctly identify when the ReportingCommand.map method is overridden and don't raise a KeyError when its not overridden. + Added check for ReportingCommand.map override in ReportingCommand.ConfigurationSettings.streaming_preop Effect: streaming_preop is only set if there's a map method override Signed-off-by: David Noble <dnoble@splunk.com>
1 parent fcea8ec commit 9b2dd75

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

splunklib/searchcommands/reporting_command.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,16 @@ def streaming_preop(self):
162162
Computed.
163163
164164
"""
165+
command = type(self.command)
166+
167+
if command.map == ReportingCommand.map:
168+
return ""
169+
165170
command_line = str(self.command)
166171
command_name = type(self.command).name
167172
text = ' '.join([
168173
command_name, '__map__', command_line[len(command_name) + 1:]])
174+
169175
return text
170176

171177
#endregion
@@ -196,15 +202,15 @@ def fix_up(cls, command):
196202
if command.reduce == ReportingCommand.reduce:
197203
raise AttributeError('No ReportingCommand.reduce override')
198204

205+
if command.map == ReportingCommand.map:
206+
cls._requires_preop = False
207+
return
208+
199209
f = vars(command)['map'] # Function backing the map method
200210
# There is no way to add custom attributes to methods. See
201211
# [Why does setattr fail on a method](http://goo.gl/aiOsqh)
202212
# for an explanation.
203213

204-
if f == vars(ReportingCommand)['map']:
205-
cls._requires_preop = False
206-
return
207-
208214
try:
209215
settings = f._settings
210216
except AttributeError:

0 commit comments

Comments
 (0)