apache/druid · error · ParseException

Failed to deserialize Thrift data

Error message

Failed to deserialize Thrift data

What it means

toFlattenedMap() wraps TException (raised by ThriftDeserialization.detectAndDeserialize when the bytes are not valid Thrift data in any supported protocol, or by JSON serialization) and IOException into a ParseException. It fires on malformed or schema-incompatible records in the input stream — the bytes cannot be read into the configured TBase.

Solutions

  1. Verify the thriftClass setting points at a concrete generated TBase class, not an interface or abstract type
  2. Confirm the generated Thrift class is compiled with a public no-arg constructor and is on the classpath
  3. Regenerate the Thrift classes from the correct IDL if a wrong/legacy class is deployed
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftReader.java:117 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftReader.java:117

  @Override
  protected List<Map<String, Object>> toMap(byte[] intermediateRow) throws IOException
  {
    return Collections.singletonList(toFlattenedMap(intermediateRow));
  }

  private Map<String, Object> toFlattenedMap(byte[] bytes) throws ParseException
  {
    try {
      final Class<TBase> clazz = getThriftClass();
      final TBase tbase = clazz.newInstance();
      ThriftDeserialization.detectAndDeserialize(bytes, tbase);
      final String json = ThriftDeserialization.SERIALIZER_SIMPLE_JSON.get().toString(tbase);
      final JsonNode node = OBJECT_MAPPER.readTree(json);
      return recordFlattener.flatten(node);
    }
    catch (TException | IOException e) {
      throw new ParseException(null, e, "Failed to deserialize Thrift data");
    }
    catch (InstantiationException | IllegalAccessException e) {
      throw new ParseException(null, e, "Failed to instantiate Thrift class [%s]", thriftClassName);
    }
    catch (ClassNotFoundException e) {
      throw new ParseException(null, e, "Thrift class [%s] not found", thriftClassName);
    }
  }

  @SuppressWarnings({"unchecked", "ReturnValueIgnored"})
  private Class<TBase> getThriftClass() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
  {
    if (thriftClass == null) {
      final Class<TBase> clazz;
      if (jarPath != null) {
        File jar = new File(jarPath);
        URLClassLoader child = new URLClassLoader(
            new URL[]{jar.toURI().toURL()},

View on GitHub (pinned to 9b90983fd2)