Healy-Hyperspatial/stac-fastapi-mongo

Search query response contains empty `links` array when at the last page of pagination.

Closed this issue · 2 comments

Describe the bug
Search query response contains empty links array when at the last page of pagination.

To Reproduce

  1. Run app docker-compose up
  2. Create test collection
  3. Creation 1 test item
  4. Run search query with "limit":1 -> Response will contain an empty links array.
  5. Create 1 more test item.
  6. Run search query with "limit":1
  7. Run search query with the next page body -> Response will contain an empty links array.

Expected behavior
links should always contain:

{
	"rel": "root",
	"type": "application/json",
	"href": "http://localhost:8084/"
},
{
	"rel": "self",
	"type": "application/json",
	"href": "http://localhost:8084/search"
}

Noticed this doesn't happen in sfeos core because it always returns a next token even if it's the last page of the pagination.

ok issue is because sfeos core only generates links if there is a next_token:

https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/f797ed4f449a40c52337ba1c451a597aa8a3f2e7/stac_fastapi/core/stac_fastapi/core/core.py#L321-L323

        links = []
        if next_token:
            links = await PagingLinks(request=request, next=next_token).get_links()