atproto icon indicating copy to clipboard operation
atproto copied to clipboard

Query with limit=1 returns empty for non-empty feed - app.bsky.feed.getAuthorFeed

Open oestradiol opened this issue 5 months ago • 1 comments

Describe the bug

If you pass the query filters...

  • limit=1;
  • filter=posts_and_author_threads
  • no cursor (although I didn't test with a cursor, but the idea is fetching the latest post, so I don't think this will be particularly relevant)

...to app.bsky.feed.getAuthorFeed, and the last post the person made was deleted, it returns an empty feed (as if they had 0 posts) instead of their actual last available post.

To Reproduce

Steps to reproduce the behavior:

  1. Make sure you have at least one post;
  2. Post or Repost anything;
  3. Undo the previous action;
  4. Issue a request: {{your_pds}}/xrpc/app.bsky.feed.getAuthorFeed?actor={{your_did}}&filter=posts_and_author_threads&limit=1

Expected behavior

One would expect the XRPC to return an array containing the last available post.

Additional context

I'm not sure because haven't read much of this codebase, but I think it might be related to this: The field nullsLast is undefined by default... https://github.com/bluesky-social/atproto/blob/c5b765d043d3a1e934d6444decf3940968230f5f/packages/bsky/src/data-plane/server/db/pagination.ts#L135-L152 ...and should be for getAuthorFeed too, since it's not set here: https://github.com/bluesky-social/atproto/blob/c5b765d043d3a1e934d6444decf3940968230f5f/packages/bsky/src/data-plane/server/routes/feeds.ts#L48-L52 Because of that, it reaches this query if statement: https://github.com/bluesky-social/atproto/blob/c5b765d043d3a1e934d6444decf3940968230f5f/packages/bsky/src/data-plane/server/db/pagination.ts#L156-L158

According to the Postgres documentation (and as mentioned on line 141 of pagination.ts above): image

oestradiol avatar Sep 06 '24 00:09 oestradiol