Skip to content

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

Merged
awalker4 merged 2 commits into
mainfrom
austin/unbound-element
Oct 20, 2023
Merged

awalker4 merged 2 commits into
mainfrom
austin/unbound-element

Conversation

@awalker4

Copy link
Copy Markdown
Collaborator

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.

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

Copy link
Copy Markdown
Contributor

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

@Coniferish Coniferish left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@awalker4
awalker4 merged commit 414ea67 into main Oct 20, 2023
@awalker4
awalker4 deleted the austin/unbound-element branch October 20, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants