datalad / datalad-next

DataLad extension for new functionality and improved user experience
https://datalad.org
Other
7 stars 8 forks source link

`uncurl` gives unintelligible error on "access denied" #326

Open mih opened 1 year ago

mih commented 1 year ago

I am using addurls and it triggers uncurl. I entered the wrong password and I get an incomprehensible error message:

addurls(error): /tmp/dummy/P000624_dicom.tar (file) [AnnexBatchCommandError(AnnexBatchCommandError: 'addurl' [Error, annex reported failure for addurl (url='https://xxx/P000624_dicom.tar'): {'command': 'addurl', 'error-messages': ['  CHECKURL failed with no reason given'], 'file': 'P000624_dicom.tar', 'input': ['https://xxx/P000624_dicom.tar P000624_dicom.tar'], 'success': False}])] [AnnexBatchCommandError: 'addurl' [Error, annex reported failure for addurl (url='https://xxx/P000624_dicom.tar'): {'command': 'addurl', 'error-messages': ['  CHECKURL failed with no reason given'], 'file': 'P000624_dicom.tar', 'input': ['https://xxx/P000624_dicom.tar P000624_dicom.tar'], 'success': False}]]
[ERROR  ] BatchedAnnex(command=['git', '-c', 'diff.ignoreSubmodules=none', 'annex', 'addurl', '--with-files', '--json', '--json-error-messages', '--batch'], encoding=UTF-8, exception_on_timeout=False, generator=<datalad.runner.nonasyncrunner._ResultGenerator object at 0x7f51e1777910>, last_request=('https://xxx/P000624_dicom.tar', 'P000624_dicom.tar'), output_proc=<function readline_json at 0x7f51e26596c0>, path=/tmp/dummy, return_code=None, runner=<datalad.runner.runner.WitlessRunner object at 0x7f51e176cdf0>, stderr_output=b'addurl: 1 failed\n', stdin_queue=<queue.Queue object at 0x7f51e174fdd0>, timeout=None, wait_timed_out=None) subprocess exited with 1 (CommandError: 'git -c diff.ignoreSubmodules=none annex addurl --with-files --json --json-error-messages --batch' failed with exitcode 1) 

The error messaging on a plain download is not any better. Here I am intentionally providing the wrong password:

❯ datalad get otherP000624_dicom.tar
Total:   0%|                                                                   | 0.00/792M [00:00<?, ? Bytes/s]Credential needed for access to https://data.inm-icf.de/dl-Z03/P000624_dicom.tar
user: myuser
password: 
password (repeat): 
get(error): otherP000624_dicom.tar (file) [Failed to download 'MD5E-s792207360--985e680a221e47db05063a12b91d7d89.tar' from any of ['https://data.inm-icf.de/dl-Z03/P000624_dicom.tar']]

and via git annex also not much better

❯ git annex get otherP000624_dicom.tar
get otherP000624_dicom.tar (from uncurl...) 
Credential needed for access to https://data.inm-icf.de/dl-Z03/P000624_dicom.tar
user: myuser

password: 
password (repeat): 

  Failed to download 'MD5E-s792207360--985e680a221e47db05063a12b91d7d89.tar' from any of ['https://data.inm-icf.de/dl-Z03/P000624_dicom.tar']

  Unable to access these remotes: uncurl

  No other repository is known to contain the file.
failed
get: 1 failed
mih commented 1 year ago

It seems that uncurl could be given a wrapper around the various handler(url) calls that makes better use of the exception behavior of the URLOperations framework. At present, only the genric UrlOperationsRemoteError is caught when a permission error occurs.

It remains a question what the exact behavior on permission denied would be.

we cannot simply keep asking.