bluesky-social / atproto

Social networking technology created by Bluesky
Other
6.13k stars 432 forks source link

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

Open oestradiol opened 1 week ago

oestradiol commented 1 week ago

Describe the bug

If you pass the query filters...

...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 commented 1 week ago

Update: Mary (@mary-ext) mentioned something relevant, so I'm adding this here.

"posts_and_author_threads have an additional filter that's done outside of a db query so part of it could be that"