Page MenuHomeSoftware Heritage

REST server: add validation for PID parameters
ClosedPublic

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

Details

Reviewers
seirl
Summary

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

Repository
rDGRPH Graph service
Branch
feature/param-validation
Lint
No Linters Available
Unit
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.Fri, Nov 8, 8:36 PM
zack edited the summary of this revision. (Show Details)Fri, Nov 8, 8:39 PM
seirl accepted this revision.Tue, Nov 12, 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.Tue, Nov 12, 1:15 AM
zack updated this revision to Diff 7765.Tue, Nov 12, 8:49 AM

REST server: add validation for PID parameters

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