Page MenuHomeSoftware Heritage

api/vault: Fix 404 handling and improve error messages
ClosedPublic

Authored by anlambert on May 5 2020, 4:12 PM.

Details

Summary

Vault 404 error handling needed to be updated since changes related to
exception handling server side.

Also improve returned error messages, add missing test and slightly
refactor tests implementation (use hypothesis instead of harcoded data).

Closes T2388

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 created this revision.May 5 2020, 4:12 PM

Build is green

Patch application report for D3125 (id=11098)

Rebasing onto 97c8291f0b...

Current branch diff-target is up to date.
Changes applied before test
commit 09b19ae4b94e045f22c50aae2239b2f1694455bd
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue May 5 16:09:28 2020 +0200

    api/vault: Fix 404 handling and improve error messages
    
    Vault 404 error handling needed to be updated since changes related to
    exception handling server side.
    
    Also improve returned error messages, add missing test and slightly
    refactor tests implementation (use hypothesis instead of harcoded data).
    
    Closes T2388

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/115/ for more details.

I think I can improve on this, let me check if it works

er wait, I thought you said you would fix swh-vault??

er wait, I thought you said you would fix swh-vault??

Oh you mean catch the exception in the client part of the vault ?

I think I can improve on this, let me check if it works

I let you handle the vault part then, I will adapt the diff accordingly (only keeping improved tests and error messages)

vlorentz added a comment.EditedMay 5 2020, 5:03 PM

Hmm, actually, the vault already behaves as I wanted.

I don't know why swh-web stopped working, then.

anlambert added a comment.EditedMay 5 2020, 5:08 PM

I don't know why swh-web stopped working, then.

Because of the changes regarding response handling server side I describe in https://forge.softwareheritage.org/T2388#44140 (The 404 error response was catched and None was returned instead of raising an exception).

Oh, right!

I'll make the RPC client re-raise the vault's NotFoundExc so you can catch it properly

ardumont added inline comments.
swh/web/common/service.py
1095

With D3127, can be except (swh.vault.exc.)NotFound... now ;)

(i may be off on the swh.vault.exception module ;)

anlambert updated this revision to Diff 11107.May 5 2020, 6:02 PM

Update: Synchronize with latest changes in swh-vault

ardumont accepted this revision.May 5 2020, 6:06 PM

Nice.

(some copyright date range headers are off but besides that, cool)

(also debian vault build is fine \m/)

This revision is now accepted and ready to land.May 5 2020, 6:06 PM
anlambert updated this revision to Diff 11108.May 5 2020, 6:08 PM

Bump swh.vault in requirements-swh.txt and update years in license headers.

(some copyright date range headers are off but besides that, cool)

Done, and we should definitely write a pre-commit hook for that ;-)

Build is green

Patch application report for D3125 (id=11107)

Rebasing onto 97c8291f0b...

Current branch diff-target is up to date.
Changes applied before test
commit 5b4ba39266345d0de63a17e1eb0fd8675ab341e0
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue May 5 16:09:28 2020 +0200

    api/vault: Fix 404 handling and improve error messages
    
    Vault 404 error handling needed to be updated since changes related to
    exception handling server side.
    
    Also improve returned error messages, add missing test and slightly
    refactor tests implementation (use hypothesis instead of harcoded data).
    
    Closes T2388

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/116/ for more details.

Build is green

Patch application report for D3125 (id=11108)

Rebasing onto 97c8291f0b...

Current branch diff-target is up to date.
Changes applied before test
commit affd506bc632882492a291cac08fb93886fb42e3
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue May 5 16:09:28 2020 +0200

    api/vault: Fix 404 handling and improve error messages
    
    Vault 404 error handling needed to be updated since changes related to
    exception handling server side.
    
    Also improve returned error messages, add missing test and slightly
    refactor tests implementation (use hypothesis instead of harcoded data).
    
    Closes T2388

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/117/ for more details.