{"record":{"id":"d663ed48ba9522c2","repo":"apache/druid","slug":"protobuf-message-could-not-be-parsed","errorCode":null,"errorMessage":"Protobuf message could not be parsed","messagePattern":"Protobuf message could not be parsed","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/ProtobufInputRowSchema.java","lineNumber":74,"sourceCode":"    }\n\n    /**\n     * Extracts the timestamp from the record. If the timestamp column is of complex type such as {@link Timestamp},\n     * then the timestamp is first serialized to string via {@link JsonFormat}. Directly calling {@code toString()}\n     * on {@code Timestamp} returns an unparseable string.\n     */\n    @Override\n    @Nullable\n    public DateTime extractTimestamp(@Nullable Map<String, Object> input)\n    {\n      Object rawTimestamp = getRawTimestamp(input);\n      if (rawTimestamp instanceof Message) {\n        try {\n          String timestampStr = JsonFormat.printer().print((Message) rawTimestamp);\n          return parseDateTime(timestampStr);\n        }\n        catch (InvalidProtocolBufferException e) {\n          throw new ParseException(null, e, \"Protobuf message could not be parsed\");\n        }\n      } else {\n        return parseDateTime(rawTimestamp);\n      }\n    }\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/protobuf-extensions/src/main/java/org/apache/druid/data/input/protobuf/ProtobufInputRowSchema.java#L56-L82","documentation":"When the timestamp column of a protobuf record is itself a protobuf Message, ProtobufInputRowSchema.extractTimestamp prints it as JSON via JsonFormat and parses the resulting string as a date. If JsonFormat printing throws InvalidProtocolBufferException (e.g. Any messages that cannot be resolved), Druid wraps it in a ParseException with this message.","triggerScenarios":"The input row schema's timestamp field resolves to a Message object and JsonFormat.printer().print(...) throws InvalidProtocolBufferException — typically for google.protobuf.Any containing an unregistered/unresolvable type URL.","commonSituations":"Using a google.protobuf.Any (or Struct/Value) as the queryable timestamp column; an Any with a type_url not on the Druid classpath so JsonFormat cannot resolve its type.","solutions":["Use a scalar (int64/string) or google.protobuf.Timestamp field as the timestamp column instead of an arbitrary message","If Any is required, ensure the embedded type's descriptor is registered on the Druid classpath","Catch and inspect the wrapped cause in a custom parser to identify which message failed"],"exampleFix":"// before: timestamp_column points at a google.protobuf.Any field\n\"timestampColumn\": \"metadata\"\n// after: point at a Timestamp or scalar field\n\"timestampColumn\": \"event_time\"","handlingStrategy":"try-catch","validationCode":"Object ts = ...; // resolved timestamp field\nif (ts instanceof Message\n    && \"google.protobuf.Any\".equals(((Message) ts).getDescriptorForType().getFullName())) {\n  throw new IllegalStateException(\"Any is not usable as timestamp column; use Timestamp or scalar\");\n}","typeGuard":"boolean isUsableTimestamp(Object raw) {\n  return raw == null || !(raw instanceof Message)\n      || \"google.protobuf.Timestamp\".equals(((Message) raw).getDescriptorForType().getFullName());\n}","tryCatchPattern":"try {\n  ingest(record);\n} catch (ParseException e) {\n  if (\"Protobuf message could not be parsed\".equals(e.getMessage()) && e.getCause() instanceof InvalidProtocolBufferException) {\n    log.error(\"Unparseable timestamp message — check Any type_url resolution\", e.getCause());\n  }\n}","preventionTips":["Point timestampColumn at a scalar or google.protobuf.Timestamp field, not Any/Struct","Register all Any-embedded message types on the Druid classpath","Test the inputFormat spec against sample records before production ingestion"],"tags":["protobuf","timestamp","json-format"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}