Skip to content

fix Pleroma search API incompatibility with empty limit param #977

Closed
@snarfed

Description

Pleroma supports the Mastodon API, so a number of people have already signed their Pleroma accounts up for Bridgy via the Mastodon support. And it works!

...at least, mostly. Publish seems pretty functional, and listen (aka backfeed) has worked before, but right now it's hitting the API incompatibility below. Evidently Mastodon's /api/v2/search endpoint handles a blank value for the limit query param ok, but Pleroma doesn't. cc @jk-na etc.

I 2020-09-27 22:40:01.151421 requests.get https://toot.icyphox.sh/api/v2/search {'params': {'q': 'icyphox.sh', 'resolve': True, 'offset': 0, 'limit': ''}, 'headers': {'Authorization': '...'}}
I 2020-09-27 22:40:02.334777 Redirected to https://toot.icyphox.sh/api/v2/search?q=icyphox.sh&resolve=True&offset=0&limit=
E 2020-09-27 22:40:02.338004 Error 400, response body: '{"error":"limit - Invalid integer. Got: string.","errors":[{"message":"Invalid integer. Got: string","source":{"pointer":"/limit"},"title":"Invalid value"}]}'
Traceback (most recent call last):
...
  File "/srv/tasks.py", line 86, in post
    self.poll(source)
  File "/srv/tasks.py", line 134, in poll
    links = source.search_for_links()
  File "/srv/mastodon.py", line 148, in search_for_links
    return self.get_activities(
  File "/srv/models.py", line 393, in get_activities
    return self.get_activities_response(**kwargs)['items']
  File "/srv/models.py", line 387, in get_activities_response
    resp = self.gr_source.get_activities_response(**kwargs)
  File "/layers/google.python.pip/pip/granary/mastodon.py", line 197, in get_activities_response
    statuses = self._get(API_SEARCH, params={
  File "/layers/google.python.pip/pip/granary/mastodon.py", line 120, in _get
    return self._api(util.requests_get, *args, **kwargs)
  File "/layers/google.python.pip/pip/granary/mastodon.py", line 135, in _api
    resp.raise_for_status()
  File "/layers/google.python.pip/pip/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://toot.icyphox.sh/api/v2/search?q=icyphox.sh&resolve=True&offset=0&limit=

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions