[4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

When things don't work as they should.
Post Reply
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

[4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

Hi everyone!

I recently updated to 4.1 and now I'm unable to search for documents. I get an error 504 on the frontend and I get the error message below in the logs. Manually looking up and displaying the document still works though.

Unfortunately, googling the error message came up with virtually nothing. :(
I checked my docker compose files against the "official" ones and couldn't find anything about files in any way.

Does anyone have an idea what this might be?

Thanks

Cheers
Bebef

Error message:

Code: Select all

mayan.apps.sources.tasks <516> [ERROR] "task_source_process_document() line 42 Error processing source id: 4; local variable 'shared_uploaded_files' referenced before assignment"
Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 38, in task_source_process_document
    source.get_backend_instance().process_documents(dry_run=dry_run)
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/mixins.py", line 113, in process_documents
    for self.shared_uploaded_file in self.get_shared_uploaded_files() or ():
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/email_backends.py", line 201, in get_shared_uploaded_files
    return shared_uploaded_files
UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment
[2021-11-08 06:55:17,449: ERROR/ForkPoolWorker-1] Error processing source id: 4; local variable 'shared_uploaded_files' referenced before assignment
Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 38, in task_source_process_document
    source.get_backend_instance().process_documents(dry_run=dry_run)
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/mixins.py", line 113, in process_documents
    for self.shared_uploaded_file in self.get_shared_uploaded_files() or ():
  File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/email_backends.py", line 201, in get_shared_uploaded_files
    return shared_uploaded_files
UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment
Last edited by bebef on Wed Nov 10, 2021 2:23 pm, edited 1 time in total.
DrRSatzteil
Posts: 30
Joined: Mon Oct 26, 2020 11:38 pm

Re: [4.1] UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by DrRSatzteil »

I had the same issue but the upgrade to 4.1.3 solved this for me.
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

Re: [4.1] UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

Good for you!

I unfortunately already are at 4.1.3 :(
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

Re: [4.1] UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

I also checked upgrade notes etc., but didn't find anything in particular regarding my issue.
DrRSatzteil
Posts: 30
Joined: Mon Oct 26, 2020 11:38 pm

Re: [4.1] UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by DrRSatzteil »

Hm... that's too bad. I also searched for the error message but could not find anything. As I realised that another version had been released shortly after I assumed that this issue was fixed before a lot of users updated to the version continaing this error. Unfortunately I can't really help here since I simply "fixed" the problem by upgrading. :(
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

Re: [4.1] UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

Okay, so the error message is just a red herring. I have no idea why it would pop up whenever I perform a search, but it does...
I removed the email source configuration, now the error is gone.

Unfortunately, I am still unable to search. This time however, I get an http 502 instead. I see load (increasing) on the PostgreSQL database, but like I said, get an error instead of the search result.

I have re-created the mail source and the error reappeared.
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

Re: [4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

I have tried to replicate the error in a new docker stack. Unfortunately, in the new stack, I don't get the same error (with the same sources configuration), which means that I'm sort of stuck here :(
bebef
Posts: 21
Joined: Fri Aug 21, 2020 6:00 am

Re: [4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by bebef »

Okay, so although I still have the log entries on every single "execution" of my IMAP source, the source itself seems to work, i.e. the documents sent to the email address will end up in my Mayan installation. So I wonder if the log messages are just "cosmetic"? :?
User avatar
michael
Developer
Developer
Posts: 209
Joined: Sun Apr 19, 2020 6:21 am

Re: [4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by michael »

Hello,

Running the test suit did not trigger the issue you describe.

I've logged and internal ticket to examine the code more closely for an untested code path.

Thanks for the report. Cheers!
DrRSatzteil
Posts: 30
Joined: Mon Oct 26, 2020 11:38 pm

Re: [4.1] Mail Source: UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment

Post by DrRSatzteil »

I just realized that in fact I still do see this error in the logs... Sorry for the confusion I was talking about a different error in my previous post...

Could this be an additional log statement that has been added following my error report here? viewtopic.php?t=4927

Code: Select all

UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment
app_1                     | mayan.apps.sources.tasks <607> [ERROR] "task_source_process_document() line 42 Error processing source id: 17; local variable 'shared_uploaded_files' referenced before assignment"
app_1                     | Traceback (most recent call last):
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 38, in task_source_process_document
app_1                     |     source.get_backend_instance().process_documents(dry_run=dry_run)
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/mixins.py", line 113, in process_documents
app_1                     |     for self.shared_uploaded_file in self.get_shared_uploaded_files() or ():
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/email_backends.py", line 263, in get_shared_uploaded_files
app_1                     |     return shared_uploaded_files
app_1                     | UnboundLocalError: local variable 'shared_uploaded_files' referenced before assignment
app_1                     | [2021-11-21 22:12:27,347: ERROR/ForkPoolWorker-76] Error processing source id: 17; local variable 'shared_uploaded_files' referenced before assignment
app_1                     | Traceback (most recent call last):
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/tasks.py", line 38, in task_source_process_document
app_1                     |     source.get_backend_instance().process_documents(dry_run=dry_run)
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/mixins.py", line 113, in process_documents
app_1                     |     for self.shared_uploaded_file in self.get_shared_uploaded_files() or ():
app_1                     |   File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/source_backends/email_backends.py", line 263, in get_shared_uploaded_files
app_1                     |     return shared_uploaded_files
Post Reply