apache/druid · error · InvalidProtocolBufferException

Invalid Wrapper type.

Error message

Invalid Wrapper type.

What it means

During protobuf message conversion Druid looks up a specialized converter for google.protobuf wrapper types (BoolValue, Int32Value, etc.). The converter expects the well-known wrapper message shape with a single 'value' field. When the descriptor of the message registered as a wrapper type has no 'value' field, this InvalidProtocolBufferException is thrown, indicating the runtime descriptor does not match the expected well-known type layout.

Source

Thrown at extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/ProtobufConverter.java:163

          return ((Descriptors.EnumValueDescriptor) value).getName();
        }
      case MESSAGE:
      case GROUP:
        return convertMessage((Message) value);
      default:
        // pass through everything else
        return value;
    }
  }

  private static Map<String, SpecializedConverter> buildSpecializedConversions()
  {
    final Map<String, SpecializedConverter> converters = new HashMap<>();
    final SpecializedConverter parappaTheWrappa = msg -> {
      final Descriptors.Descriptor descriptor = msg.getDescriptorForType();
      final Descriptors.FieldDescriptor valueField = descriptor.findFieldByName("value");
      if (valueField == null) {
        throw new InvalidProtocolBufferException("Invalid Wrapper type.");
      }
      return convertSingleValue(valueField, msg.getField(valueField));
    };
    converters.put(BoolValue.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(Int32Value.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(UInt32Value.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(Int64Value.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(UInt64Value.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(StringValue.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(BytesValue.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(FloatValue.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(DoubleValue.getDescriptor().getFullName(), parappaTheWrappa);
    converters.put(
        Any.getDescriptor().getFullName(),
        msg -> JsonFormat.printer().print(msg) // meh
    );
    converters.put(
        Timestamp.getDescriptor().getFullName(),

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check the classpath for duplicate/mismatched com.google.protobuf:protobuf-java versions (mvn dependency:tree) and align them with the version Druid's protobuf-extensions uses
  2. Ensure no custom descriptor pool registers messages with google.protobuf.* full names that shadow the real well-known types
  3. Upgrade the protobuf-extensions / protobuf-java to matching versions and redeploy the extension

Example fix

// before: mixed protobuf versions on classpath
protobuf-java 3.7.x shaded inside a custom extension jar
// after: single aligned version in the extension pom
<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java</artifactId>
  <version>3.25.1</version>
</dependency>
Defensive patterns

Strategy: validation

Validate before calling

Descriptors.Descriptor d = msg.getDescriptorForType();
if ("google.protobuf.BoolValue".equals(d.getFullName()) && d.findFieldByName("value") == null) {
  throw new IllegalStateException("Descriptor for " + d.getFullName() + " lacks 'value' field; check protobuf-java version on classpath");
}

Type guard

boolean isValidWrapper(Message msg) {
  return msg.getDescriptorForType().findFieldByName("value") != null;
}

Try / catch

try {
  Map<String, Object> row = ProtobufConverter.convertMessage(msg);
} catch (InvalidProtocolBufferException e) {
  if (e.getMessage().contains("Invalid Wrapper type")) {
    log.error("Wrapper descriptor mismatch — check protobuf-java versions", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: A field whose descriptor full name matches a registered wrapper type (e.g. google.protobuf.StringValue) is encountered during convertMessage, but its descriptor lacks a field named 'value' — practically only when a custom/older protobuf runtime provides different well-known type descriptors or the message descriptor was shadowed.

Common situations: Mismatched or shaded protobuf-runtime versions on the classpath (e.g. an old com.google.protobuf jar bundled by an extension or a fat jar) where well-known type descriptors differ; custom descriptor pools where a message reuses a google.protobuf.* full name.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/d6fdc752e1e6825b. Report an issue: GitHub.