quarkusio/quarkus · error · RuntimeException
RuntimeException(e)
Error message
RuntimeException(e)
What it means
InvokeCommand builds the request message from JSON using JsonFormat.parser().merge into a DynamicMessage. If the supplied JSON does not conform to the proto (bad types, unknown fields, malformed JSON), InvalidProtocolBufferException is wrapped in RuntimeException and thrown, aborting the invocation.
Source
Thrown at extensions/grpc/cli/src/main/java/io/quarkus/grpc/cli/InvokeCommand.java:78
});
}
} else {
err("Unexpected response from server reflection: " + responseCase);
}
return null;
}).await().indefinitely();
}
private void invokeMethod(Descriptors.MethodDescriptor md) {
String fullMethodName = md.getService().getFullName() + "/" + md.getName();
Descriptors.Descriptor inputType = md.getInputType();
DynamicMessage.Builder messageBuilder = DynamicMessage.newBuilder(inputType);
try {
content.ifPresent(request -> {
try {
JsonFormat.parser().merge(request, messageBuilder);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
});
DynamicMessage msg = messageBuilder.build();
MethodDescriptor.MethodType methodType = MethodDescriptor.MethodType.UNARY;
if (md.isClientStreaming()) {
methodType = MethodDescriptor.MethodType.CLIENT_STREAMING;
}
if (md.isServerStreaming()) {
methodType = MethodDescriptor.MethodType.SERVER_STREAMING;
}
if (md.isClientStreaming() && md.isServerStreaming()) {
methodType = MethodDescriptor.MethodType.BIDI_STREAMING;
}
MethodDescriptor<DynamicMessage, DynamicMessage> methodDescriptor = io.grpc.MethodDescriptor
.<DynamicMessage, DynamicMessage> newBuilder()
.setType(methodType)
.setFullMethodName(fullMethodName)
.setRequestMarshaller(ProtoUtils.marshaller(DynamicMessage.getDefaultInstance(inputType)))View on GitHub (pinned to e1c734241f)
Solutions
- Validate the JSON against the proto message definition (check field names/types via `quarkus grpc describe`)
- Use correct protobuf JSON conventions: camelCase names, base64 for bytes, strings for int64
- Escape the JSON properly on the shell (single quotes) so it reaches the parser intact
Example fix
// before
String req = "{user_id: 42}"; // proto syntax, not JSON
cli.invokeMethod(..., Optional.of(req), ...); // RuntimeException
// after
String req = "{\"userId\": 42}"; // valid protobuf JSON
cli.invokeMethod(..., Optional.of(req), ...); Defensive patterns
Strategy: validation
Validate before calling
// Validate JSON parses and matches proto JSON rules before invoking:
try {
new com.fasterxml.jackson.databind.ObjectMapper().readTree(requestJson);
} catch (Exception e) {
throw new IllegalArgumentException("Request JSON is malformed: " + e.getMessage());
}
// then check field names against `quarkus grpc describe MyService` output Type guard
boolean isValidJson(String s) {
try { new ObjectMapper().readTree(s); return true; }
catch (Exception e) { return false; }
} Try / catch
try {
command.invokeMethod(...);
} catch (RuntimeException e) {
if (e.getCause() instanceof InvalidProtocolBufferException ipbe) {
System.err.println("JSON does not match proto: " + ipbe.getMessage());
}
} Prevention
- Generate request JSON from the describe output instead of hand-writing it
- Use protobuf JSON conventions: camelCase field names, base64 bytes, ISO strings for timestamps
- Quote JSON correctly in the shell (single quotes) to avoid mangling
When it happens
Trigger: `quarkus grpc invoke` where the --request/-j JSON string mismatches the method's input type: wrong field names, string given for number, invalid base64 for bytes, malformed JSON syntax.
Common situations: Copy-pasting JSON shaped for a REST API instead of the proto message; camelCase vs snake_case field naming mistakes; passing JSON for the wrong method after refactoring.
Related errors
- RuntimeException(e)
- RuntimeException(e)
- More than one @QuarkusMain method found with name '${name}':
- Build metrics file cannot be read:
- Build report file cannot be written to:
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ca34df36bc499bcc.
Report an issue: GitHub.