UAL-RE / LD-Cool-P

Python tool to enable data curation
MIT License
4 stars 5 forks source link

Bug: failure handling error of TinuURL API calls #259

Closed zoidy closed 1 year ago

zoidy commented 1 year ago

Describe the bug LD-Cool-P fails to correctly handle exceptions related to creating TinyURL links. This means that if an error happens, subsequent links for that dataset wont get generated

Reproduction Steps Run get_qualtrics for a dataset that generates a TinyURL error

Outputted Messages URLs have been redacted

8:01:24 -     INFO: TinyURL link does not exist. Creating!
18:01:25 -  WARNING: Caught an HTTPError: 400 Client Error: Bad Request for url: http://tinyurl.com/api-create.php?url=xxxxxx
--- Logging error ---
Traceback (most recent call last):
  File "/home/curator/codes/LD_Cool_P/ldcoolp/curation/email/urls.py", line 56, in tiny_url
    response.raise_for_status()
  File "/home/curator/.local/lib/python3.7/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://tinyurl.com/api-create.php?url=xxxxxx

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/curation/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/opt/anaconda3/envs/curation/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/opt/anaconda3/envs/curation/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/opt/anaconda3/envs/curation/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/curator/codes/LD_Cool_P/ldcoolp/scripts/generate_qualtrics_links", line 93, in <module>
    da_tinyurl = urls.tiny_url(full_url, alias=da_alias)
  File "/home/curator/codes/LD_Cool_P/ldcoolp/curation/email/urls.py", line 60, in tiny_url
    log.warning('Body:\n', response.text)
Message: 'Body:\n'
Arguments: ('Error',)
Traceback (most recent call last):
  File "/home/curator/codes/LD_Cool_P/ldcoolp/curation/email/urls.py", line 56, in tiny_url
    response.raise_for_status()
  File "/home/curator/.local/lib/python3.7/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://tinyurl.com/api-create.php?url=xxxxxx

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/curator/codes/LD_Cool_P/ldcoolp/scripts/generate_qualtrics_links", line 93, in <module>
    da_tinyurl = urls.tiny_url(full_url, alias=da_alias)
  File "/home/curator/codes/LD_Cool_P/ldcoolp/curation/email/urls.py", line 61, in tiny_url
    raise HTTPError
requests.exceptions.HTTPError

Version information

Expected behavior Execution continues with a warning logged

zoidy commented 1 year ago

This bug surfaced due to the bug in #261

zoidy commented 1 year ago

fixed in #260