splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

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

Open lowell80 opened this issue 6 years ago • 8 comments

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 avatar Feb 24 '20 22:02 lowell80

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

lowell80 avatar Mar 09 '20 19:03 lowell80

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

shakeelmohamed avatar Mar 09 '20 19:03 shakeelmohamed

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.

bakermat avatar Apr 23 '20 01:04 bakermat

@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

shakeelmohamed avatar Apr 23 '20 16:04 shakeelmohamed

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

fantavlik avatar Apr 23 '20 20:04 fantavlik

Thanks!

bakermat avatar Apr 23 '20 22:04 bakermat

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'

maheshba18 avatar Apr 29 '20 12:04 maheshba18

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.

fantavlik avatar Jun 01 '20 02:06 fantavlik