Skip to content

Fix "Parse message failed" error in WebRTC Signaling Demo Project #1209

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Switchbreak
Copy link

The _parse_msg method type-checks parsed JSON numeric values to require integers, however JSON.parse_string always returns floats, leading to a "Parse message failed" error when running the demo.

Issue link: godotengine/godot#103374

JSON.parse_string will always return float for numeric values
@Calinou Calinou added the bug label Jun 6, 2025
@@ -207,7 +207,7 @@ func _parse_msg(peer: Peer) -> bool:
if typeof(parsed) != TYPE_DICTIONARY or not parsed.has("type") or not parsed.has("id") or \
typeof(parsed.get("data")) != TYPE_STRING:
return false
if not str(parsed.type).is_valid_int() or not str(parsed.id).is_valid_int():
if not typeof(parsed.type) == Variant.Type.TYPE_FLOAT or not typeof(parsed.id) == Variant.Type.TYPE_FLOAT:
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified to the following:

Suggested change
if not typeof(parsed.type) == Variant.Type.TYPE_FLOAT or not typeof(parsed.id) == Variant.Type.TYPE_FLOAT:
if parsed.type is not float or parsed.id is not float:

If not, this can be simplified to:

	if not typeof(parsed.type) == TYPE_FLOAT or not typeof(parsed.id) == TYPE_FLOAT:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants