{"record":{"id":"d0b3bc7f4ea218cd","repo":"grpc/grpc-java","slug":"message-of-wrapped-invalidprotocolbufferexception","errorCode":null,"errorMessage":"(message of wrapped InvalidProtocolBufferException)","messagePattern":"\\(message of wrapped InvalidProtocolBufferException\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoLiteUtils.java","lineNumber":275,"sourceCode":"\n    private final T defaultInstance;\n\n    MetadataMarshaller(T defaultInstance) {\n      this.defaultInstance = defaultInstance;\n    }\n\n    @Override\n    public byte[] toBytes(T value) {\n      return value.toByteArray();\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public T parseBytes(byte[] serialized) {\n      try {\n        return (T) defaultInstance.getParserForType().parseFrom(serialized, globalRegistry);\n      } catch (InvalidProtocolBufferException ipbe) {\n        throw new IllegalArgumentException(ipbe);\n      }\n    }\n  }\n}\n","sourceCodeStart":257,"sourceCodeEnd":280,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoLiteUtils.java#L257-L280","documentation":"ProtoLiteUtils' MethodDescriptor Marshaller.parseBytes parses protobuf messages from bytes using the lite runtime with a global extension registry. When the lite parser throws InvalidProtocolBufferException (malformed wire format, unknown fields that cannot be skipped, or missing required extensions), it is rethrown as an IllegalArgumentException wrapping the original exception — so the informative message lives in the cause.","triggerScenarios":"Any gRPC call using protobuf-lite marshalling where the received message bytes fail protobuf parsing: wrong message type on a method, corrupted/truncated frame, sender using proto2 required fields not set, or a serializer/deserializer version mismatch.","commonSituations":"Client and server disagree on the RPC message type for a method, mixing protobuf-lite and full protobuf with incompatible generated code, network middleboxes corrupting payloads, or deserializing a response from a service that changed its schema.","solutions":["Inspect the cause chain (IllegalArgumentException#getCause) to see the real InvalidProtocolBufferException message identifying the wire-format problem.","Confirm client and server generated code come from the same .proto version and both use protobuf-lite consistently.","Verify the RPC method is invoked with the correct request/response message types matching the service definition.","Check for version skew: redeploy both ends with matching grpc-protobuf-lite and generated stub versions."],"exampleFix":"// before\nFoo foo = stub.getFoo(request); // fails with opaque IllegalArgumentException\n// after\ntry {\n  Foo foo = stub.getFoo(request);\n} catch (IllegalArgumentException e) {\n  log.error(\"protobuf parse failed\", e.getCause()); // InvalidProtocolBufferException details\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  T msg = marshaller.parseBytes(serialized);\n} catch (IllegalArgumentException e) {\n  Throwable cause = e.getCause(); // InvalidProtocolBufferException with the real reason\n  throw new Status.INTERNAL.withCause(cause).withDescription(\"bad protobuf\").asRuntimeException();\n}","preventionTips":["Always inspect getCause() — the wrapper message is uninformative by design.","Keep generated protobuf code and grpc-protobuf-lite versions in lockstep across services.","Verify client and server agree on the method's request/response message types.","Enable wire-format logging when debugging interop between protobuf-lite and full protobuf."],"tags":["grpc","protobuf","deserialization","lite-runtime"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}