Page 1 of 1

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

Posted: Mon Nov 08, 2021 7:14 am
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

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

Posted: Tue Nov 09, 2021 9:25 pm
by DrRSatzteil
I had the same issue but the upgrade to 4.1.3 solved this for me.

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

Posted: Wed Nov 10, 2021 7:47 am
by bebef
Good for you!

I unfortunately already are at 4.1.3 :(

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

Posted: Wed Nov 10, 2021 8:14 am
by bebef
I also checked upgrade notes etc., but didn't find anything in particular regarding my issue.

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

Posted: Wed Nov 10, 2021 9:50 am
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. :(

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

Posted: Wed Nov 10, 2021 2:22 pm
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.

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

Posted: Thu Nov 11, 2021 1:52 pm
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 :(

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

Posted: Sun Nov 14, 2021 9:26 am
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"? :?

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

Posted: Sun Nov 14, 2021 10:49 am
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!

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

Posted: Sun Nov 21, 2021 9:22 pm
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