unioslo / tsd-api-client

Command line client for the TSD HTTP API
BSD 3-Clause "New" or "Revised" License
13 stars 5 forks source link

UnboundLocalError: cannot access local variable 'data' where it is not associated with a value #147

Open knutj opened 3 months ago

knutj commented 3 months ago

Traceback (most recent call last): File "/home/knutjb/python311/bin/tacl", line 8, in sys.exit(cli()) ^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/click/core.py", line 783, in invoke return __callback(args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/tsdapiclient/tacl.py", line 644, in cli resp = initiate_resumable( ^^^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/tsdapiclient/fileapi.py", line 813, in initiate_resumable return _start_resumable( ^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/tsdapiclient/tools.py", line 190, in decorator return f(args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/home/knutjb/python311/lib64/python3.11/site-packages/tsdapiclient/fileapi.py", line 914, in _start_resumable upload_id = data['id'] ^^^^ UnboundLocalError: cannot access local variable 'data' where it is not associated with a value

haatveit commented 3 months ago

Hi, and thank you for filing an issue for this.

Can you please help us debug the problem by providing information about how you are invoking tacl when this exception occurs?

knutj commented 3 months ago

tacl p11 --upload local.tar.gz , I can not provide the user group or the name of the file. It is running on Fedora 41 with Python 3.11 as virtuelenv

haatveit commented 2 weeks ago

Sorry about the late follow-up to this issue.

After investing the problem last week, I figured out that the specific problem you ran into was being caused by the code path responsible for retrying requests on temporary HTTP errors from the API, and wrote a fix for it in 2495a7965bee8ad80537216ebd90a27538aff6c6.

As the retry manager would silently abort execution of code ran within its context, I unfortunately lack details about what exactly went wrong when you hit this issue in the first place, but most likely the API raised an error when tacl was attempting to initiate an upload session.

Have you ran into this bug again after making this issue? If it happens consistently, please contact our technical support team with details you can't provide publicly, and if possible, timestamps for when the problem occurred would be much appreciated.

I've published a small version update containing last week's fix:

https://pypi.org/project/tsd-api-client/3.5.15/