Page MenuHomeSoftware Heritage

REST server: add validation for PID parameters

Authored by zack on Nov 8 2019, 8:36 PM.



This is still very basic and can be improved.

For one thing, the try/except blocks are repeated, but I'm not sure what's the
best way to refactor this stuff in aiohttp. (Is there a notion of global
excepton handler for routes?)

Second, I'm only validating PID parameters here, while others are given, such
as directions, edge restrictions, etc. They should all be checked for validity
and trigger bad request return codes rather then making the REST server explode
in the backend.

Third, tests for the returned HTTP status codes are missing, but it's not clear
to me yet how we're currently testing the HTTP layer of the REST server.

I'm also pushing this to the branch feature/param-validation, feel free to give
me feedback here but also make improvements directly in that branch.

Diff Detail

rDGRPH Graph service
No Linters Available
No Unit Test Coverage
Build Status
Buildable 8947
Build 13070: tox-on-jenkinsJenkins
Build 13069: arc lint + arc unit

Event Timeline

zack created this revision.Nov 8 2019, 8:36 PM
zack edited the summary of this revision. (Show Details)Nov 8 2019, 8:39 PM
seirl accepted this revision.Nov 12 2019, 1:15 AM

This looks good, I agree more stuff needs to be generalized in the whole aiohttp side anyway... And I'm also not sure how to do it properly, so I think this is good for now.

This revision is now accepted and ready to land.Nov 12 2019, 1:15 AM
zack updated this revision to Diff 7765.Nov 12 2019, 8:49 AM

REST server: add validation for PID parameters

zack updated this revision to Diff 7768.Nov 12 2019, 12:20 PM
  • REST server: validate all query parameters and refactor validators
zack closed this revision.Nov 12 2019, 12:25 PM

Closed in cc712446e8ef1e6aa7bf23488108778d5f847897