-
Notifications
You must be signed in to change notification settings - Fork 133
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
fix: discord webhook embed timestamp fails to serialize #555
Conversation
for more information, see https://pre-commit.ci
these are like syntactically identical under the hood so i'd like to understand what the issue is i'm not convinced there's an issue when this exists: |
have a sample error traceback for the issue @minisbett? |
Ah I found in discord,
|
Did you migrate your bancho.py to use httpx? Looks like master is using aiohttp and the exception mentions httpx. |
Ah nvm I understand - @tsunyoku I think you linked non-master code |
ok can we fix by changing httpx's serialization then? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @tsunyoku touched on ^, having this as a global configuration for the JSON serialization of the services.http_client
would be a more desirable change - as this issue may exist in several other code spots.
I suspect there should be a way to hook the JSON serialization - we shouldn't need to use httpx.request(content=...)
.
yup, getting that error elsewhere as well. |
I found this comment/discussion while browsing the issues on the httpx repo: I think this comment is true - it should be possible to subclass |
Hm, in the current We can subclass Alternatively we could hook Might actually be best overall to make a PR to class APIClient(httpx.Client):
request_class = APIRequest
response_class = APIResponse
class APIRequest(httpx.Request):
def __init__(self, *args, **kwargs):
if 'json' in kwargs:
content = orjson.dumps(kwargs.pop('json'))
headers = kwargs.get('headers', {})
headers['Content-Length'] = len(content)
kwargs['content'] = content
kwargs['headers'] = headers
return super().__init__(*args, **kwargs)
class APIResponse(httpx.Response):
def json(self):
return orjson.loads(self.content) |
I'll turn this into an issue as I think implementation is a bit pre-mature - will tag everyone there for further discussion |
Describe your changes
The timestamp of embeds on a webhook fail to serialize into JSON properly.
Checklist