splunk / splunk-sdk-python

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

TextIOWrapper regression bug in 1.6.12: 'file' object has no attribute 'readable' #307

Closed lowell80 closed 4 years ago

lowell80 commented 4 years ago

I think I stumbled onto a bug in 1.6.12 that impacts at least 7.1.4 and 7.3.0. It seems to be related to python 2 vs 3 and athe TextIOWrapper around the output stream. The initial registration seems to be fine (--scheme), but whenever the script is run to collect data that's when it fails.

When I downgrade splunk-sdk version to 1.6.11 my modular input (TA) works fine again.

Here's the traceback from the 1.6.12 version from a local 7.3 instance running on a Mac:

Traceback (most recent call last):
  File "/Users/lalleman/splunk73/splunk/etc/apps/TA-oam_dms/bin/OAM_DMS.py", line 422, in <module>
    sys.exit(OamDmsModularInput().run(sys.argv))
  File "/Users/lalleman/splunk73/splunk/etc/apps/TA-oam_dms/bin/../lib/splunklib/modularinput/script.py", line 56, in run
    return self.run_script(args, EventWriter(), sys.stdin)
  File "/Users/lalleman/splunk73/splunk/etc/apps/TA-oam_dms/bin/../lib/splunklib/modularinput/event_writer.py", line 49, in __init__
    self._out = TextIOWrapper(output)
AttributeError: 'file' object has no attribute 'readable'
lowell80 commented 4 years ago

BTW, I just hit this with another TA I've written. Has anyone else had issues like this?

shakeelmohamed commented 4 years ago

Hi @lowell80, this seems like an oversight in our testing. We're open to pull requests, however we do not have the bandwidth to address this issue at the moment. Thank you for your patience and understanding

bakermat commented 4 years ago

I just started writing my first TA and this issue caused me to waste hours. First thing anyone does when they start fresh is download the latest SDK version and work with that. Being new to the SDK there are a lot of things for me to learn and I never thought that the SDK would contain a bug like this, so assumed it was my script. Anyone doing something intelligent with a modular input and importing splunklib would run into this so please prioritise this issue or add it as a known issue on the releases page.

shakeelmohamed commented 4 years ago

@Bakermat We have a fix in progress in #319, however it is blocked on some CI enhancements. Thank you for your patience, we are aware of the frustration this may be causing you

fantavlik commented 4 years ago

Very sorry for your frustration @Bakermat, we should have publicized that issue more broadly once we verified it. I have taken your suggestion and added it to the known issues for the release here: https://github.com/splunk/splunk-sdk-python/releases/tag/1.6.12

bakermat commented 4 years ago

Thanks!

maheshba18 commented 4 years ago

I am also facing the same issue for my TA while using python 2 interpreter.

Below is the traceback from the 1.6.12 version from a local 8 instance running on a linux:

Traceback (most recent call last): File "/root/codebase/splunk/splunk_ta/bin/main.py", line 53, in ew = EventWriter() File "/root/codebase/splunk/splunk_ta/bin/splunklib/modularinput/event_writer.py", line 49, in init self._out = TextIOWrapper(output) AttributeError: 'file' object has no attribute 'readable'

fantavlik commented 4 years ago

We have released a fix in v1.6.13 https://github.com/splunk/splunk-sdk-python/releases/tag/1.6.13 but please let us know if you continue to see similar issues.