apache/shenyu · error · RuntimeException

Unable to merge from the supplied input stream

Error message

Unable to merge from the supplied input stream

What it means

This is the Protobuf marshaller's parse method used when the gateway decodes a gRPC message payload into a DynamicMessage. mergeFrom(inputStream) throws IOException if the underlying stream fails while reading bytes; the marshaller wraps that in a RuntimeException with this fixed message. It signals a corrupted or broken input stream, not a schema mismatch (which would be an InvalidProtocolBufferException path).

Solutions

  1. Retry the gRPC call; transient stream truncation usually resolves with a fresh request.
  2. Check connectivity and stability to the backend gRPC service (timeouts, LB health checks, proxy idle limits).
  3. Inspect the backend service logs for early connection close or panics while streaming the response.
  4. If a proxy sits between gateway and backend, raise its idle/stream timeouts and ensure it supports gRPC (HTTP/2) without buffering limits that cut frames.
Defensive patterns

Strategy: retry

Try / catch

try {
    return marshaller.parse(inputStream);
} catch (RuntimeException e) {
    if ("Unable to merge from the supplied input stream".equals(e.getMessage())
            && e.getCause() instanceof IOException) {
        // retry the upstream gRPC call on a fresh stream
    }
    throw e;
}

Prevention

When it happens

Trigger: gRPC response/request body streaming is interrupted or the InputStream supplied to parse() cannot be fully read (connection reset mid-body, truncated frame) while DynamicMessage.newBuilder(messageDescriptor).mergeFrom(...) runs.

Common situations: Unstable network between gateway and gRPC backend; backend closing the connection before the full message is sent; proxies/timeouts truncating gRPC frames; upstream servers under load dropping streams.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/9bceb2c42cf2dd1f. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-protocol/shenyu-protocol-grpc/src/main/java/org/apache/shenyu/protocol/grpc/message/JsonMessage.java:220

    /**
     * DynamicMessageMarshaller.
     */
    private static final class DynamicMessageMarshaller implements MethodDescriptor.Marshaller<DynamicMessage> {

        private final Descriptors.Descriptor messageDescriptor;

        private DynamicMessageMarshaller(final Descriptors.Descriptor messageDescriptor) {
            this.messageDescriptor = messageDescriptor;
        }

        @Override
        public DynamicMessage parse(final InputStream inputStream) {
            try {
                return DynamicMessage.newBuilder(messageDescriptor)
                        .mergeFrom(inputStream, ExtensionRegistryLite.getEmptyRegistry())
                        .build();
            } catch (IOException e) {
                throw new RuntimeException("Unable to merge from the supplied input stream", e);
            }
        }

        @Override
        public InputStream stream(final DynamicMessage abstractMessage) {
            return abstractMessage.toByteString().newInput();
        }
    }
}

View on GitHub (pinned to 567142e072)