Page MenuHomeSoftware Heritage

Fix documentation of meaning of 404 on vault endpoints.
ClosedPublic

Authored by vlorentz on Dec 16 2019, 3:01 PM.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert added a subscriber: anlambert.
anlambert added inline comments.
swh/web/api/views/vault.py
85–87

Indeed, this is the meaning of the 404 code in case of a GET request:

15:39 $ curl http://localhost:5004/api/1/vault/directory/b1483f0996e94c0c80fc76e5ef0f760fbe9a491b/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   945  100   945    0     0  37800      0 --:--:-- --:--:-- --:--:-- 37800
{
  "exception": "NotFoundExc",
  "reason": "Directory 'b1483f0996e94c0c80fc76e5ef0f760fbe9a491b' was never requested.",
  "traceback": "Traceback (most recent call last):\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/apidoc.py\", line 315, in documented_view\n    response = f(request, **kwargs)\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/vault.py\", line 90, in api_vault_cook_directory\n    res = _dispatch_cook_progress(request, 'directory', obj_id)\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/vault.py\", line 26, in _dispatch_cook_progress\n    .format(object_name, hex_id)))\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/utils.py\", line 47, in api_lookup\n    raise NotFoundExc(notfound_msg)\nswh.web.common.exc.NotFoundExc: Directory 'b1483f0996e94c0c80fc76e5ef0f760fbe9a491b' was never requested.\n"
}

But in case of a POST request, the 404 code really means that the directory is not archived:

15:38 $ curl -X POST http://localhost:5004/api/1/vault/directory/b1483f0996e94c0c80fc76e5ef0f760fbe9a491b/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   925  100   925    0     0  23125      0 --:--:-- --:--:-- --:--:-- 23125
{
  "exception": "NotFoundExc",
  "reason": "Directory 'b1483f0996e94c0c80fc76e5ef0f760fbe9a491b' not found.",
  "traceback": "Traceback (most recent call last):\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/apidoc.py\", line 315, in documented_view\n    response = f(request, **kwargs)\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/vault.py\", line 90, in api_vault_cook_directory\n    res = _dispatch_cook_progress(request, 'directory', obj_id)\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/vault.py\", line 32, in _dispatch_cook_progress\n    .format(object_name, hex_id)))\n  File \"/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/web/api/views/utils.py\", line 47, in api_lookup\n    raise NotFoundExc(notfound_msg)\nswh.web.common.exc.NotFoundExc: Directory 'b1483f0996e94c0c80fc76e5ef0f760fbe9a491b' not found.\n"
}

So to be exhaustive in the doc, both cases should be present.

This revision now requires changes to proceed.Dec 16 2019, 3:42 PM
This revision is now accepted and ready to land.Dec 18 2019, 10:45 AM
This revision was landed with ongoing or failed builds.Dec 18 2019, 5:29 PM
This revision was automatically updated to reflect the committed changes.