Menu

#272 BadZipfile exception when nothing was put in the zip file

Workflow
open
nobody
2015-01-12
2014-12-02
No

If the queueAction gets an empty zipfile it fails the route with a BadZipFile exception rather than just doing nothing. But why isn't the empty zip file just an empty zip file? instead it is an actually empty file.

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/services/process.py", line 825, in work
    action_name, description = self.run_stanza(action_uuid)
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/services/process.py", line 398, in run_stanza
    parameters=stanza.get('params'),
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/core/context.py", line 566, in run_command
    command.run()
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/core/logic/action.py", line 294, in run
    self.do_action()
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/actions/flow/queue.py", line 145, in do_action
    for handle, name, in self._yield_input_handles_and_name():
  File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/actions/flow/queue.py", line 118, in _yield_input_handles_and_name
    zfile = zipfile.ZipFile(self.rfile, 'r', )
  File "/usr/lib64/python2.6/zipfile.py", line 696, in __init__
    self._GetContents()
  File "/usr/lib64/python2.6/zipfile.py", line 716, in _GetContents
    self._RealGetContents()
  File "/usr/lib64/python2.6/zipfile.py", line 728, in _RealGetContents
    raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file

Can we somehow initialize the ZIP file so it is not just nothing? The origin of this this particular ZIP message as ftpGetFilesAction

Discussion

  • Adam Tauno Williams

    Tried a HACK to ensure the ZIP archive was initialized if it was empty. That does not appear to have worked.

    Stanza 000010
    start:ftpGetFilesAction
    debug:logic command is "action::ftp-get-files"
    debug:Connected to FTP service "eippftp.com"
    debug:Authenticated to FTP service
    debug:ZIP archive closed
    debug:Writing ZIP header for empty archive; Python is  < 2.7.1?
    debug:0 files retrieved from FTP server.
    complete:No description.
    duration:0.7281022s
    
    Stanza 000020
    start:messageToDocumentAction
    debug:logic command is "action::message-to-document"
    complete:No description.
    duration:0.5227439s
    
    Stanza 000030
    start:queueProcess
    debug:logic command is "action::queue-process"
    error:exception in stanza 000030
    Traceback (most recent call last):
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/services/process.py", line 825, in work
        action_name, description = self.run_stanza(action_uuid)
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/services/process.py", line 398, in run_stanza
        parameters=stanza.get('params'),
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/core/context.py", line 566, in run_command
        command.run()
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/core/logic/action.py", line 294, in run
        self.do_action()
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/actions/flow/queue.py", line 145, in do_action
        for handle, name, in self._yield_input_handles_and_name():
      File "/usr/lib/python2.6/site-packages/OpenGroupware-0.1.49rc89-py2.6.egg/coils/logic/workflow/actions/flow/queue.py", line 118, in _yield_input_handles_and_name
        zfile = zipfile.ZipFile(self.rfile, 'r', )
      File "/usr/lib64/python2.6/zipfile.py", line 696, in __init__
        self._GetContents()
      File "/usr/lib64/python2.6/zipfile.py", line 716, in _GetContents
        self._RealGetContents()
      File "/usr/lib64/python2.6/zipfile.py", line 726, in _RealGetContents
        endrec = _EndRecData(fp)
      File "/usr/lib64/python2.6/zipfile.py", line 204, in _EndRecData
        return _EndRecData64(fpin, -sizeEndCentDir, endrec)
      File "/usr/lib64/python2.6/zipfile.py", line 147, in _EndRecData64
        fpin.seek(offset - sizeEndCentDir64Locator, 2)
    IOError: [Errno 22] Invalid argument
    
     
  • Adam Tauno Williams

    the attached test proves that this HACK should work

     
  • Adam Tauno Williams

    it appears that in production only four octets are actually in the output file; is this a failure to flush?

    50 4B 05 06

     
  • Adam Tauno Williams

    Nope, the simple test fails on Python 2.6

    [root@workflow tmp]# python empty-zfile-test.py 
    Traceback (most recent call last):
      File "empty-zfile-test.py", line 15, in <module>
        zfile = zipfile.ZipFile(open('testfile.zip', 'r'), 'r')
      File "/usr/lib64/python2.6/zipfile.py", line 696, in __init__
        self._GetContents()
      File "/usr/lib64/python2.6/zipfile.py", line 716, in _GetContents
        self._RealGetContents()
      File "/usr/lib64/python2.6/zipfile.py", line 726, in _RealGetContents
        endrec = _EndRecData(fp)
      File "/usr/lib64/python2.6/zipfile.py", line 204, in _EndRecData
        return _EndRecData64(fpin, -sizeEndCentDir, endrec)
      File "/usr/lib64/python2.6/zipfile.py", line 147, in _EndRecData64
        fpin.seek(offset - sizeEndCentDir64Locator, 2)
    IOError: [Errno 22] Invalid argument
    
     

Log in to post a comment.