-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ThreadMetadata#create_timestamp
is sent as null
in GUILD_CREATE#threads
#4418
Comments
Was not able to reproduce this, are you sure this is not an issue with the way you deserialize the event? {
"t": "GUILD_CREATE",
"s": 2,
"op": 0,
"d": {
...
"threads": [
{
"type": 11,
"thread_metadata": {
"locked": false,
"auto_archive_duration": 1440,
"archived": false,
"archive_timestamp": "2022-01-31T18:15:50.738443+00:00"
},
...
},
{
"type": 11,
"thread_metadata": {
"locked": false,
"create_timestamp": "2022-01-31T18:15:40.406000+00:00",
"auto_archive_duration": 4320,
"archived": false,
"archive_timestamp": "2022-01-31T18:15:40.406000+00:00"
},
...
}
],
...
}
} |
The API is sending nulls. |
Yes, I still recieve {
"threads": [
{
"type": 11,
"thread_metadata": {
"locked": false,
"invitable": true,
"create_timestamp": null,
"auto_archive_duration": 10080,
"archived": false,
"archive_timestamp": "2021-12-21T04:03:10.474000+00:00"
},
"rate_limit_per_user": 0,
"parent_id": "xxxxxxx",
"owner_id": "xxxxxxx",
"name": "hug thread",
"message_count": 50,
"member_count": 14,
"last_message_id": "xxxxxxx",
"id": "xxxxxxx",
"guild_id": "xxxxxxx"
}
]
} (You'll notice one of the threads disappeared since I just took this snapshot of the sent JSON now) I'm pretty sure no steps of deserialization is messing up, as this is roughly what I did: async for message in websocket:
res = json.loads(message) # python's json module
if res['t'] == 'GUILD_CREATE' and res['d']['id'] == 'xxxxxxx':
with open('guild.json', 'wb') as f:
f.write(message.encode()) I then checked |
Older threads won't have the create timestamp set for them, there's nothing I can really do about that. It'll never be null or missing for newly created threads though, if you have a newly created thread that has it missing/null, feel free to reopen though! |
@ajpalkovic the issue is that according to the documentation it can't be null (only absent), but the gateway behavior specifically is different |
It's actually not even "gateway behavior", i bet something like thread_update would not set it to null, it's probably only guild_create and thread_list_sync that do, too bad. I could fix it, but caches, you know, so probably best just to say it can be null then if it's a problem for y'all? |
While acceptable that caches may cache the invalid value for some time, it would be even better if the API was (eventually) consistent in when it sends which fields with what values. |
For me it's more that: it's fixed for newly created threads and consistent for them, and all the old threads will eventually auto-archive anyway, so by the time that data is evicted from the "cache" they'll probably be archived anyway and it would be a moot point. And if I do fix this issue, it's just one line, it means that things would become more inconsistent because you cannot know if a given old thread will have null or have the field omitted. So that's why I was leaning towards "do nothing", but LMK if you disagree. |
But this issue is simply prompted by the incorrect documentation. In my library that's statically typed this causes a deserialization error. If you intend to keep the behavior that doesn't match the docs that's fine, but don't close the issue until the documentation is amended. The issue was never about whether this behavior should change or not.
|
Description
ThreadMetadata#create_timestamp
is documented as optional, non-nullable in the docs. With REST, it apparantly follows this documentation. However for gateway, it is sent asnull
inGUILD_CREATE
'sthreads
attribute.(Am I surprised that this happens? No. But I'm not making a PR because I am unsure if this is intentional.)
Steps to Reproduce
GUILD_CREATE
for that guild and itsthreads
attribute. See "Current Behavior" for an example of this.Expected Behavior
The docs don't lie to me.
Current Behavior
The docs lie to me.
Here's how Python's
json
module parsedGuildCreateEvent#theads
:Screenshots/Videos
No response
Client and System Information
My own library, but with everything skipped except json parsing.
The text was updated successfully, but these errors were encountered: