splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
687 stars 369 forks source link

Ensure event XML is a string before writing. #303

Closed jmg292 closed 2 years ago

jmg292 commented 4 years ago

Fixes following issue. See stacktrace.

Traceback (most recent call last): File "/Applications/Splunk/etc/apps/TA-1password/bin/ta_1password/aob_py3/modinput_wrapper/base_modinput.py", line 128, in stream_events self.collect_events(ew) File "/Applications/Splunk/etc/apps/TA-1password/bin/onepassword_event_logs.py", line 76, in collect_events input_module.collect_events(self, ew) File "/Applications/Splunk/etc/apps/TA-1password/bin/input_module_onepassword_event_logs.py", line 216, in collect_events event_stream.stream_events(CACHE_FOLDER, stanza_name) File "/Applications/Splunk/etc/apps/TA-1password/bin/input_module_onepassword_event_logs.py", line 175, in stream_events self._process_event(event, input_name) File "/Applications/Splunk/etc/apps/TA-1password/bin/input_module_onepassword_event_logs.py", line 150, in _process_event SplunkWriter.write_event(splunk_event) File "/Applications/Splunk/etc/apps/TA-1password/bin/onepassword_lib/splunk_writer.py", line 10, in write_event SplunkWriter.writer.write_event(event) File "/Applications/Splunk/etc/apps/TA-1password/bin/ta_1password/aob_py3/solnlib/packages/splunklib/modularinput/event_writer.py", line 57, in write_event event.write_to(self._out) File "/Applications/Splunk/etc/apps/TA-1password/bin/ta_1password/aob_py3/splunklib/modularinput/event.py", line 107, in write_to stream.write(ET.tostring(event)) TypeError: write() argument must be str, not bytes

ashah-splunk commented 2 years ago

@jmg292 thank you for the PR. The fix for the issue mentioned has already been fixed and present in the latest version of the SDK. Would request you to try with the latest version and let us know if the issue still exists.