disgoorg / disgo

A modular Golang Discord API Wrapper
Apache License 2.0
333 stars 37 forks source link

Failed to parse gateway message #372

Closed ImVexed closed 2 months ago

ImVexed commented 3 months ago

Describe the bug Seeing lots of snowflake parsing logs

Error

ERROR error while parsing gateway message name=gateway shard_id=0 shard_count=1 err="failed to unmarshal message data: {\"t\":\"GUILD_CREATE\",\"s...: failed to unquote snowflake: invalid syntax"

To Reproduce Seems to be happening for presence updates as well.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Disgo Version(please complete the following information): github.com/disgoorg/disgo v0.18.8 github.com/disgoorg/snowflake/v2 v2.0.1 Additional context Add any other context about the problem here.

topi314 commented 2 months ago

discord sending ids as non strings again bruh, can you enable debug logs and send those so we can see which field is causing this?

in case you dont know how you should just need this line at the start of your program

slog.SetLogLoggerLevel(slog.LevelDebug)
ImVexed commented 2 months ago

I'm not seeing any more specific field failure logs, just the same error messages. For presence updates it's:

2024/07/19 15:33:59 ERROR error while parsing gateway message name=gateway shard_id=0 shard_count=1 err="failed to unmarshal message data: {\"t\":\"PRESENCE_UPDATE\",\"s\":328,\"op\":0,\"d\":{\"user\":{\"id\":\"1214960289343348779\"},\"status\":\"online\",\"guild_id\":\"412794678791110664\",\"client_status\":{\"desktop\":\"online\"},\"broadcast\":null,\"activities\":[{\"type\":0,\"timestamps\":{\"start\":1721401839000},\"name\":\"TLauncher\",\"id\":\"c747a5611b48b02b\",\"details\":\"Vues de la page d'accueil\",\"created_at\":1721401839648,\"assets\":{\"large_image\":\"1142030771398385665\"},\"application_id\":\"1140558605771350016\"},{\"type\":0,\"state\":\"with Medal.tv\",\"session_id\":\"8419ad9930d88b0759363ef310e544d9\",\"name\":\"Medal\",\"id\":\"30523a5df503d9a3\",\"details\":\"Recently clipped Minecraft\",\"created_at\":1721403236352,\"buttons\":[\"Follow on Medal\",\"Download Medal\"],\"assets\":{\"large_text\":\"Minecraft\",\"large_image\":\"859167360925564958\"},\"application_id\":\"307998818547531777\"},{\"type\":0,\"timestamps\":{\"start\":1721377578201},\"state\":\"Joue a Grand Theft Auto VI\",\"session_id\":\"8419ad9930d88b0759363ef310e544d9\",\"name\":\"Grand Theft Auto VI\",\"id\":\"e1b62882f0b1f451\",\"flags\":1,\"details\":\"Bienvenue a Vice City!\",\"created_at\":1721377582295,\"buttons\":[\"Jouer a Grand Theft Auto VI\"],\"assets\":{\"large_image\":\"mp:attachments/1221893448110575669/1262758010069979168/1635795-la-sortie-de-grand-theft-auto-vi-est-prevue-pour-l-annee-2025.png?ex=6697c28a&is=6696710a&hm=8a92d346a018b513a9f679cf0f8f084c54855d26eaf0e9f9da2da16e6b9c006e&\"},\"application_id\":1}]}}: failed to unmarshal event data: {\"user\":{\"id\":\"1214960289343348779\"},\"status\":\"online\",\"guild_id\":\"412794678791110664\",\"client_status\":{\"desktop\":\"online\"},\"broadcast\":null,\"activities\":[{\"type\":0,\"timestamps\":{\"start\":1721401839000},\"name\":\"TLauncher\",\"id\":\"c747a5611b48b02b\",\"details\":\"Vues de la page d'accueil\",\"created_at\":1721401839648,\"assets\":{\"large_image\":\"1142030771398385665\"},\"application_id\":\"1140558605771350016\"},{\"type\":0,\"state\":\"with Medal.tv\",\"session_id\":\"8419ad9930d88b0759363ef310e544d9\",\"name\":\"Medal\",\"id\":\"30523a5df503d9a3\",\"details\":\"Recently clipped Minecraft\",\"created_at\":1721403236352,\"buttons\":[\"Follow on Medal\",\"Download Medal\"],\"assets\":{\"large_text\":\"Minecraft\",\"large_image\":\"859167360925564958\"},\"application_id\":\"307998818547531777\"},{\"type\":0,\"timestamps\":{\"start\":1721377578201},\"state\":\"Joue a Grand Theft Auto VI\",\"session_id\":\"8419ad9930d88b0759363ef310e544d9\",\"name\":\"Grand Theft Auto VI\",\"id\":\"e1b62882f0b1f451\",\"flags\":1,\"details\":\"Bienvenue a Vice City!\",\"created_at\":1721377582295,\"buttons\":[\"Jouer a Grand Theft Auto VI\"],\"assets\":{\"large_image\":\"mp:attachments/1221893448110575669/1262758010069979168/1635795-la-sortie-de-grand-theft-auto-vi-est-prevue-pour-l-annee-2025.png?ex=6697c28a&is=6696710a&hm=8a92d346a018b513a9f679cf0f8f084c54855d26eaf0e9f9da2da16e6b9c006e&\"},\"application_id\":1}]}: failed to unquote snowflake: invalid syntax"

But I'm not sure about posting the intial gateway message as it's like 3Mb, followed by a "one of those fields isn't a snowflake"

topi314 commented 2 months ago

bruh \"application_id\":1 there seems to be an open issue on discords end: https://github.com/discord/discord-api-docs/issues/6763

topi314 commented 2 months ago

I think the initial guild create also contains the presences, hence why the both error

ImVexed commented 2 months ago

Yes, \"application_id\":1, is present in the ERROR error while parsing gateway message name=gateway shard_id=0 shard_count=1 err="failed to unmarshal message data: {\"t\":\"GUILD_CREATE\" sync message

topi314 commented 2 months ago

since this issue seems to be happening quite frequently with discord I went ahead and added an option to allow for unquoted ids in the snowflake package

you can enable this by setting snowflake.AllowUnquoted = true and go getting https://github.com/disgoorg/disgo/commit/bc3930878ecbb7c6b89c02247c3ff2d818bdd044

this will also be included in the next release

topi314 commented 2 months ago

I would not recommend to turn this option on unless you get this error tbh, this is just to workaround discords incompetence to address these issues in a timely manner

ImVexed commented 2 months ago

after enabling snowflake.AllowUnquoted = true

ERROR error while parsing gateway message name=gateway shard_id=0 shard_count=1 err="failed to unmarshal message data: {\"t\":\"PRESENCE_UPDATE\",\"s\":15001,\"op\":0,\"d\":{\"user\":{\"id\":\"1015370136045228112\"},\"status\":\"dnd\",\"guild_id\":\"412794678791110664\",\"client_status\":{\"desktop\":\"dnd\"},\"broadcast\":null,\"activities\":[{\"type\":0,\"timestamps\":{\"start\":1721340000922},\"state\":\"Ticket na Cash Mods\",\"session_id\":\"18551ae30f2c038415a2eaf3f616ee45\",\"name\":\"bobusss\",\"id\":\"146c7a3ce0041e7b\",\"flags\":1,\"details\":\"Pomoc z modsami i reduxami?\",\"created_at\":1721417629055,\"buttons\":[\"Cash Mods\",\"YouTube\"],\"assets\":{\"large_image\":\"mp:attachments/908084735719403521/1242513635201519739/a787c37735287b605d185019707cec71.png?ex=667c40ff&is=667aef7f&hm=49f61926c8a2685413b10737f5dbbffa4ccc3d7b1b8d352effdd14ad5ceb9876&\"},\"application_id\":1}]}}: failed to unmarshal event data: {\"user\":{\"id\":\"1015370136045228112\"},\"status\":\"dnd\",\"guild_id\":\"412794678791110664\",\"client_status\":{\"desktop\":\"dnd\"},\"broadcast\":null,\"activities\":[{\"type\":0,\"timestamps\":{\"start\":1721340000922},\"state\":\"Ticket na Cash Mods\",\"session_id\":\"18551ae30f2c038415a2eaf3f616ee45\",\"name\":\"bobusss\",\"id\":\"146c7a3ce0041e7b\",\"flags\":1,\"details\":\"Pomoc z modsami i reduxami?\",\"created_at\":1721417629055,\"buttons\":[\"Cash Mods\",\"YouTube\"],\"assets\":{\"large_image\":\"mp:attachments/908084735719403521/1242513635201519739/a787c37735287b605d185019707cec71.png?ex=667c40ff&is=667aef7f&hm=49f61926c8a2685413b10737f5dbbffa4ccc3d7b1b8d352effdd14ad5ceb9876&\"},\"application_id\":1}]}: failed to parse snowflake as uint64: strconv.ParseUint: parsing \"\": invalid syntax"
topi314 commented 2 months ago

my logic was a bit flawed lol, try this commit please: https://github.com/disgoorg/disgo/commit/564ae163b9bb6ea2e3263503eb6bbb927166ae87

ImVexed commented 2 months ago

That worked, not seeing errors anymore

sebm253 commented 2 months ago

this has been fixed as of https://github.com/disgoorg/disgo/releases/tag/v0.18.9, please update to this version if you're experiencing this issue and check the release notes for instructions.