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

/api/v2/search will always return ones own account, no matter the offset #11365

Closed
connyduck opened this issue Jul 19, 2019 · 3 comments · Fixed by #11525

Comments

@connyduck
Copy link
Contributor

commented Jul 19, 2019

TL;DR searching for your own account breaks pagination

Expected behaviour

When I search for my own username with Search v2 api and a really high offset, I get no results.

https://mastodon.social/api/v2/search?type=accounts&q=connyduck&resolve=true&limit=20&offset=300&following=false

{
    "accounts": [],
    "statuses": [],
    "hashtags": []
}

Actual behaviour

https://mastodon.social/api/v2/search?type=accounts&q=connyduck&resolve=true&limit=20&offset=300&following=false

{
    "accounts": [
        {
            // my own account
        }
    ],
    "statuses": [],
    "hashtags": []
}

My own account is always returned, no matter what offset I send in.

Steps to reproduce the problem

Send a search request for your own username and any offset.

Specifications

Could reproduce on multiple mastodon instances, all running v2.9.2.
Problem does not occur when the search query does not return my own account.

@ThibG

This comment has been minimized.

Copy link
Collaborator

commented Jul 19, 2019

Hm, this is because the search endpoint will return the account matching exactly the query if there is one.
That is, if you have a user whose name is exactly “connyduck” on your local instance, it will always return just that, it's a different query than the one affected by offsets.

This behavior is probably not expected from users, thought, we should probably restrict the exact match logic to full handles, not just bare usernames.

@connyduck

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

Okay, yes, the bug occurs with every exact match, not only my own username.

But how am I supposed to use this API? I cannot reliably detect that there are no more results if it will always return results.

@ThibG

This comment has been minimized.

Copy link
Collaborator

commented Jul 19, 2019

I guess as a workaround, you should ignore the exact match :/

And a proper fix would probably be to exclude the exact match if the offset is non-zero

@Gargron Gargron added the bug label Aug 5, 2019

Gargron added a commit that referenced this issue Aug 8, 2019
Gargron added a commit that referenced this issue Aug 10, 2019
Gargron added a commit that referenced this issue Aug 10, 2019
Gargron added a commit that referenced this issue Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.