You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GET /failures fails (500) for page tokens ending in a line break #420
GET /failures answers 500 Internal Server Error instead of 400 Bad Request for a pageToken with a line break at the end, e.g. pageToken=1.000000000000000000000000%0A.
Cause
The schema checks pageToken only against its pattern ^[0-9]{1,15}\.[0-9a-f]{24}$. jsonschema matches patterns with Python's re.search(), where $ also matches before a final line break (see elixir-cloud-aai/foca#797). The token then reaches _after() in cloud_registry/ga4gh/registry/failures.py, and ObjectId("<24 hex digits>\n") raises bson.errors.InvalidId, which FOCA serves as 500.
The other ^...$ patterns of additions.openapi.yaml aren't affected: $ only appears there inside negative lookaheads (serviceId, id of renames, subject, group), where it rejects more values, not fewer, and the values aren't parsed further.
Fix
Check the token again in the controller with re.fullmatch() and answer 400 with the parameter in errors (pattern-mismatch), without quoting the token, as drs-filer does for its page tokens (elixir-cloud-aai/drs-filer#140). Regression test in tests/test_failures.py.
Activity
docs: say which page tokens get 400