Skip to content

[ROS2] Proposed fix: unsafe UTF-8 slicing in server.py causes JSON truncation #175

@BG2EBZ

Description

@BG2EBZ

Describe the bug
I'm currently using the ROS–TCP–Endpoint (ROS2) in my research project.

While running communication tests between Unity and ROS 2, I found a decoding issue in server.py that can cause incoming JSON payloads to be truncated.

Specifically, the current line:

message_json = data.decode("utf-8")[:-1]

unconditionally removes the last byte of the message.

Expected behavior
The decoded JSON string should be preserved intact.

Replacing the line with the following resolves the issue:

message_json = data.decode("utf-8")

Environment (please complete the following information, where applicable):

  • ROS machine OS + version: [Ubuntu 22.04 (LTS), ROS 2 Humble]
  • ROS–Unity communication: [Direct TCP over LAN]
  • Branch or version: [main-ros2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions