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

ValueError from /api/v2/users/login/twitter/ #61

Open
BenSturmfels opened this issue Aug 28, 2023 · 0 comments
Open

ValueError from /api/v2/users/login/twitter/ #61

BenSturmfels opened this issue Aug 28, 2023 · 0 comments

Comments

@BenSturmfels
Copy link
Contributor

This is a longstanding issue that hasn't ever been high enough priority to report.

We don't use the Twitter social login, but get the occasional bot hitting it, causing an unhandled error. Can be reproduced like this:

curl -H "Referer: http://example.com" http://127.0.0.1:8000/api/v2/users/login/twitter/
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

Can also be triggered via the frontend (assuming you're running the frontend on port 8001):

curl -H "Referer: http://example.com" http://127.0.0.1:8001/api/users/login/twitter/
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

Full backtrace below:

Internal Server Error: /api/v2/users/login/twitter/
Traceback (most recent call last):
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ben/work/ws/shareabouts-api/src/sa_api_v2/views/base_views.py", line 1959, in wrapper
    return view_func(request, *args, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_django/utils.py", line 46, in wrapper
    return func(request, backend, *args, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_django/views.py", line 22, in auth
    return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/actions.py", line 34, in do_auth
    return backend.start()
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/backends/base.py", line 34, in start
    return self.strategy.redirect(self.auth_url())
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/backends/oauth.py", line 180, in auth_url
    token = self.set_unauthorized_token()
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/backends/oauth.py", line 237, in set_unauthorized_token
    token = self.unauthorized_token()
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/backends/oauth.py", line 253, in unauthorized_token
    response = self.request(
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/social_core/backends/base.py", line 243, in request
    response = request(method, url, *args, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests/sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests/sessions.py", line 456, in prepare_request
    p.prepare(
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests/models.py", line 320, in prepare
    self.prepare_auth(auth, url)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests/models.py", line 551, in prepare_auth
    r = auth(self)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/requests_oauthlib/oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 351, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 165, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 247, in _render
    headers = parameters.prepare_headers(
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 25, in wrapper
    return target(params, *args, **kwargs)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/parameters.py", line 53, in prepare_headers
    escaped_value = utils.escape(value)
  File "/home/ben/work/ws/shareabouts-api/.direnv/python-3.10/lib/python3.10/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 49, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant