Skip to content

Rust+ proto decode errors due to required fields (queuedPlayers / Note.type) #81

@JonasVoet

Description

@JonasVoet

Hi! 👋

Firstly, thanks for your work on this project! 🙂

While integrating @liamcottle/rustplus.js@2.5.0 into a Rust+ desktop/web companion app, I ran into protobuf decode crashes caused by fields marked as required in rustplus.proto, even though the Rust+ API does not always include them.

I encountered crashes such as:

ProtocolError: missing required 'queuedPlayers'

and later:

ProtocolError: missing required 'type'

inside AppTeamInfo.Note.

From what I can tell, newer Rust servers sometimes omit these fields entirely, causing protobufjs to throw during decoding.

I was able to fix the issue locally by changing these fields from required to optional:

diff --git a/node_modules/@liamcottle/rustplus.js/rustplus.proto b/node_modules/@liamcottle/rustplus.js/rustplus.proto
index d893865..18f3d8c 100644
--- a/node_modules/@liamcottle/rustplus.js/rustplus.proto
+++ b/node_modules/@liamcottle/rustplus.js/rustplus.proto
@@ -229,7 +229,7 @@ message AppInfo {
 	required uint32 wipeTime = 6;
 	required uint32 players = 7;
 	required uint32 maxPlayers = 8;
-	required uint32 queuedPlayers = 9;
+	optional uint32 queuedPlayers = 9;
 	optional uint32 seed = 10;
 	optional uint32 salt = 11;
 	optional string logoImage = 12;
@@ -298,7 +298,7 @@ message AppTeamInfo {
 	}
 
 	message Note {
-		required int32 type = 2;
+		optional int32 type = 2;
 		required float x = 3;
 		required float y = 4;
 	}

It may be worth reviewing whether additional fields in the proto should also be optional to better match the current Rust+ API responses.

Thanks again for the library mate 👍

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions