Unstructured-IO / unstructured-api

Apache License 2.0
489 stars 102 forks source link

fix: fix local variable 'elements' referenced before assignment #290

Closed awalker4 closed 10 months ago

awalker4 commented 10 months ago

We've seen this error in the hosted api:

UnboundLocalError: local variable 'elements' referenced before assignment
File "prepline_general/api/general.py", line 649, in response_generator
    response = pipeline_api(
  File "prepline_general/api/general.py", line 464, in pipeline_api
    for i, element in enumerate(elements):

The if block in the check for zipfile.BadZipFile allows us to fall through without assigning elements. Instead, we should raise a 400 error when we catch this exception.

Coniferish commented 10 months ago

LGTM My only concern is casting too large a net for MS errors and overlooking something else happening. But it makes sense to remove the string check since that seems to be the only message that's returned by zipfile.BadZipFile