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

Strip the token in GatewayBot, RESTBot and RESTApp #989

Merged
merged 2 commits into from
Jan 30, 2022

Conversation

FasterSpeeding
Copy link
Collaborator

Summary

Strip the token in GatewayBot, RESTBot and RESTApp to help avoid confusing errors which most bot devs won't understand (which are similar to the following) whenever they accidentally leave a trailing newline at the end of their header (I don't like having to explain this to ppl lol)

Traceback (most recent call last):
  File "C:\Users\Lucina\PycharmProjects\hikari\test.py", line 9, in <module>
    asyncio.run(run())
  File "C:\Users\Lucina\.pyenv\pyenv-win\versions\3.10.0\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\Lucina\.pyenv\pyenv-win\versions\3.10.0\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\Lucina\PycharmProjects\hikari\test.py", line 7, in run
    await session.get("https://google.com", headers={"ok":"no\n\r"})
  File "C:\Users\Lucina\PycharmProjects\hikari\venv\lib\site-packages\aiohttp\client.py", line 557, in _request
    resp = await req.send(conn)
  File "C:\Users\Lucina\PycharmProjects\hikari\venv\lib\site-packages\aiohttp\client_reqrep.py", line 669, in send
    await writer.write_headers(status_line, self.headers)
  File "C:\Users\Lucina\PycharmProjects\hikari\venv\lib\site-packages\aiohttp\http_writer.py", line 130, in write_headers
    buf = _serialize_headers(status_line, headers)
  File "aiohttp\_http_writer.pyx", line 132, in aiohttp._http_writer._serialize_headers
  File "aiohttp\_http_writer.pyx", line 116, in aiohttp._http_writer._safe_header
ValueError: Newline or carriage return character detected in HTTP status message or header. This is a potential security issue.

But yeah for ppl who are used to being abstracted away from http semantics this won't be understandable

Checklist

  • I have run nox and all the pipelines have passed.
  • I have made unittests according to the code I have added/modified/deleted.

Related issues

Copy link
Member

@davfsa davfsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Althought I dont really like us having to do this for the user, I do understand it, so ig it is something we canhave

@FasterSpeeding FasterSpeeding merged commit e5c9f38 into hikari-py:master Jan 30, 2022
@FasterSpeeding FasterSpeeding deleted the task/strip-token branch January 30, 2022 08:58
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

Successfully merging this pull request may close these issues.

2 participants