Skip to content

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

Closed

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.

Activity

  1. tjcran commented on May 16, 2022

    @tjcran

    Marking as a Community MVP bug so that we can check again once the related endpoints are completed to see if the issue still persists.

  2. added this to the Community MVP milestone on May 16, 2022
  3. Emyrk commented on May 17, 2022

    @Emyrk
    Member

    Behavior will be to hard error

  4. Emyrk commented on Jun 2, 2022

    @Emyrk
    Member

    Completed here: #1947

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

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