uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

elAPI prints "sucessful" message when exporting data with response error #35

Closed alexander-haller closed 3 months ago

alexander-haller commented 5 months ago

In GitLab by @mhxion on May 17, 2024, 16:27

Discovered by @alexander-haller. Related to #34.

$ elapi get experiments -i 999 --export  # No experiment id with 999 exists
INFO     experiments_999 data successfully exported to /Users/<username>/Downloads/elapi/2024-05-17_150111_experiments_999.json in   export.py:71
         JSON format

$ cat /Users/<username>/Downloads/elapi/2024-05-17_150111_experiments_999.json
{
  "code": 404,
  "message": "Resource Not Found",
  "description": "The resource was not found."
}

.. data successfully exported to ... can be misleading when the response was not successful! We can remedy this by printing a different error message for when a response code is 4**, 5**. Internally, we always know if a request was actually unsuccessful, it's just the raw commands ignore any error in API response. We entirely avoid the term "successful" in the message, and instead print Warning: Request was not successful. <response <file stub name>> is exported to <path> anyway.", and exit with exit code 1.

Technically, we store API response as is from the raw commands. We can be more careful with our output message.

alexander-haller commented 5 months ago

In GitLab by @mhxion on May 17, 2024, 17:02

unassigned @mhxion

alexander-haller commented 3 months ago

In GitLab by @mhxion on Jul 1, 2024, 14:09

marked the checklist item Use <"response" <file stub name>> is exported instead of "data" for raw commands as completed

alexander-haller commented 3 months ago

In GitLab by @mhxion on Jul 1, 2024, 14:09

marked the checklist item Leave <"data" <file stub name>> is exported for plugins when we are indeed exporting things that qualify more as "data". as completed