Skip to content

Bug: Pagination breaks if the row used as cursor is deleted #1357

Closed
@mafredri

Description

@mafredri

This issue was pointed out by @spikecurtis in #1308 (comment).

Steps to Reproduce

  1. Set up coder server
  2. Request a user or template version with the after_id: GET 'http://localhost:3000/api/v2/templates/b60ecd72-9b8a-492b-b30d-077cbee5e550/versions?limit=1&after_id=49993e4e-a42f-40f3-96a8-636ac765833c'
  3. Delete the template version row in the database where id = '49993e4e-a42f-40f3-96a8-636ac765833c'
  4. Redo step 2

Expected

The API would return an error, all results or metadata related to pagination.

Actual

The API returns no results.

Notes

We're not actively using pagination yet, so this is not an immediate problem and it may not ever be a problem for the aforementioned endpoints, but it's one that we should account for. The solution could be to either never delete rows from the database (only mark as deleted) or to query the database to verify that the cursor exists, either as part of the pagination query or separately.

Keep solution as simple as possible. Throw an error if you get into a situation like this.

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions