Skip to content

Illegal Wire Type 4 (EndGroup) appended to generated gRPC response messages #561

@fabiocarneiro

Description

@fabiocarneiro

I am encountering a protocol violation where the server appends an unexpected tag to the end of a gRPC response. Specifically, after the expected fields of the response message are serialized, the stream contains an additional Field Number 12 with Wire Type 4 (EndGroup).

This causes standard Protobuf parsers and network inspectors to fail with an "Unknown or unsupported wiretype" error.

Wire Type 4 seems to be deprecated in proto3. Its presence here as a standalone "footer" violates the Proto3 wire specification and breaks compatibility with non-Kotlin gRPC clients. I suspect this started with the addition of the custom codecs, because in the latest releases (0.10.0-grpc-127 or 0.10.1-grpc-155), the same model was working fine.

Reproduction Structure

Sample .proto Definition

syntax = "proto3";

package com.example.generic;

message ChildItem {
    int64 timestamp = 1;
    double value = 2;
}

message EmptyRequest {}

message RootResponse {
    repeated ChildItem items = 1;
    string metadata = 2;
}

service ExampleService {
    rpc GetData (EmptyRequest) returns (RootResponse);
}

Evidence (Network Analysis)

Below is a breakdown of the response stream. The parser correctly iterates through the generated message fields, but fails immediately after the last valid field of the root message.

Binary Breakdown of the Malformed Footer: [Hex: 64] -> [Binary: 01100 100] -> [Field Number: 12, Wire Type: 4 (End Group)]

Inspector Log (Wireshark)

Protocol Buffers: /com.example.generic.ExampleService/GetData, response
  Message: com.example.generic.RootResponse
    Field(1): items (message)
      Value Length: 280
      items: (280 bytes)
        Message: com.example.generic.ChildItem
          Field(1): timestamp = 1738368000000 (int64)
          Field(2): value = 309883250.0 (double)
    Field(2): metadata = "sample_meta" (string)
    
    Field(12): <UNKNOWN>
      .110 0... = Field Number: 12
      .... .100 = Wire Type: End group (deprecated) (4)
      [Expert Info (Warning/Protocol): Unknown or unsupported wiretype]

Debugging and Maintenance Barriers

Investigating this issue is currently difficult due to the project's infrastructure and release workflow:

  • Lack of Snapshot/Nightly Releases: There are no automated builds for grpc-common changes. I am forced to build the project locally and publish to mavenLocal to debug. This makes it nearly impossible to provide a shareable, isolated reproduction project, as the required dependencies are not available in any public repository.
  • Build System Portability: The build process for kotlinx-rpc appears highly optimized for internal JetBrains environments. Several release tools trigger warnings regarding missing internal developer tokens, making it cumbersome for community members to contribute or verify fixes.

Proposal: Automated Releases

To improve the feedback loop for wire-protocol issues, I beg that an automated Nightly or Snapshot release mechanism for gRPC-related modules be implemented.

Moving away from manual pushes to specific grpc-release branches and providing public snapshots would:

  1. Enable users to verify fixes in real-world applications without complex local build setups.
  2. Reduce maintainer effort to release intermediate release candidate versions
  3. Allow for shareable reproductions that point to public experimental artifacts.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions