Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oestradiol opened this issue Sep 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@oestradiol
Copy link

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...

opts: {
limit?: number
cursor?: string
direction?: 'asc' | 'desc'
keyset: K
tryIndex?: boolean
// By default, pg does nullsFirst
nullsLast?: boolean
},
): QB => {
const {
limit,
cursor,
keyset,
direction = 'desc',
tryIndex,
nullsLast,
} = opts

...and should be for getAuthorFeed too, since it's not set here:
builder = paginate(builder, {
limit,
cursor,
keyset,
})

Because of that, it reaches this query if statement:
.if(!nullsLast, (q) =>
q.orderBy(keyset.primary, direction).orderBy(keyset.secondary, direction),
)

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

@oestradiol oestradiol added the bug Something isn't working label Sep 6, 2024
@oestradiol
Copy link
Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant