Skip to content

fix(api): return 400 for malformed pagination params - #505

Open
rshdhere wants to merge 1 commit into
Netflix:masterfrom
rshdhere:fix/pagination-param-validation
Open

rshdhere wants to merge 1 commit into
Netflix:masterfrom
rshdhere:fix/pagination-param-validation

Conversation

@rshdhere

Copy link
Copy Markdown
  • Add parse_limit to services/data/db_utils.py: empty or missing _limit keeps the default of 50 and values above 500 are capped as before, while non-integer, zero and negative values raise ValueError
  • Use it in all 9 paginated metadata service listings (flows, runs, steps, tasks, run and task metadata, run, step and task artifacts), returning 400 "Invalid limit" instead of a 500 with a traceback for e.g. _limit=abc, and instead of a silent empty page for _limit=0 or _limit=-1
  • Make decode_cursor reject cursors that decode to non-object JSON or whose cursor keys hold null or non-scalar values, so these return 400 "Invalid cursor" instead of raising TypeError in the handlers
  • Add unit tests for parse_limit and decode_cursor, and an integration test that sends invalid _limit and _cursor values to every paginated route

Closes #503

- Add parse_limit to services/data/db_utils.py: empty or missing _limit keeps
  the default of 50 and values above 500 are capped as before, while
  non-integer, zero and negative values raise ValueError
- Use it in all 9 paginated metadata service listings (flows, runs, steps,
  tasks, run and task metadata, run, step and task artifacts), returning
  400 "Invalid limit" instead of a 500 with a traceback for e.g. _limit=abc,
  and instead of a silent empty page for _limit=0 or _limit=-1
- Make decode_cursor reject cursors that decode to non-object JSON or whose
  cursor keys hold null or non-scalar values, so these return 400
  "Invalid cursor" instead of raising TypeError in the handlers
- Add unit tests for parse_limit and decode_cursor, and an integration test
  that sends invalid _limit and _cursor values to every paginated route

Closes Netflix#503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata service: malformed _limit or _cursor returns 500 with a traceback instead of 400

1 participant