{"record":{"id":"793edf7912ffea52","repo":"apache/druid","slug":"avrobytesdecoder-is-required-to-decode-avro-record","errorCode":null,"errorMessage":"avroBytesDecoder is required to decode Avro records","messagePattern":"avroBytesDecoder is required to decode Avro records","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroStreamInputFormat.java","lineNumber":53,"sourceCode":"\npublic class AvroStreamInputFormat extends NestedInputFormat\n{\n  private final boolean binaryAsString;\n  private final boolean extractUnionsByType;\n\n  private final AvroBytesDecoder avroBytesDecoder;\n\n  @JsonCreator\n  public AvroStreamInputFormat(\n      @JsonProperty(\"flattenSpec\") @Nullable JSONPathSpec flattenSpec,\n      @JsonProperty(\"avroBytesDecoder\") AvroBytesDecoder avroBytesDecoder,\n      @JsonProperty(\"binaryAsString\") @Nullable Boolean binaryAsString,\n      @JsonProperty(\"extractUnionsByType\") @Nullable Boolean extractUnionsByType\n  )\n  {\n    super(flattenSpec);\n    if (avroBytesDecoder == null) {\n      throw new IAE(\"avroBytesDecoder is required to decode Avro records\");\n    }\n    this.avroBytesDecoder = avroBytesDecoder;\n    this.binaryAsString = binaryAsString != null && binaryAsString;\n    this.extractUnionsByType = extractUnionsByType != null && extractUnionsByType;\n  }\n\n  @Override\n  public boolean isSplittable()\n  {\n    return false;\n  }\n\n  @JsonProperty\n  public AvroBytesDecoder getAvroBytesDecoder()\n  {\n    return avroBytesDecoder;\n  }\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/AvroStreamInputFormat.java#L35-L71","documentation":"AvroStreamInputFormat cannot decode Avro records without knowing how the raw bytes were serialized, so the avroBytesDecoder property is mandatory. Constructing the input format (e.g. from an inputFormat spec) with a null decoder throws IllegalArgumentException.","triggerScenarios":"Creating an AvroStreamInputFormat where the \"avroBytesDecoder\" field is absent or null in the JSON inputFormat spec — e.g. an avro bytes decoder spec missing its \"type\" so it deserializes to null, or the field omitted entirely.","commonSituations":"Typos in the decoder type name (e.g. \"avro_bytes_decoder\") causing failed JSON binding; copying an old inputFormat example that predates the avroBytesDecoder requirement; programmatically building the object without passing a decoder.","solutions":["Add a valid avroBytesDecoder spec to the inputFormat, e.g. {\"type\":\"schema_registry\",\"url\":\"http://registry:8081\"} or {\"type\":\"inline_schema\"} / {\"type\":\"multiple_schemas\", ...}.","Verify the decoder \"type\" value matches a registered AvroAvroBytesDecoder subclass; fix typos so Jackson binds it instead of leaving the field null.","If constructing in Java, pass a non-null AvroBytesDecoder implementation (e.g. new SchemaRegistryAvroBytesDecoder(...))."],"exampleFix":"// before\n\"inputFormat\": {\"type\": \"avro\", \"flattenSpec\": {...}}\n// after\n\"inputFormat\": {\"type\": \"avro\", \"avroBytesDecoder\": {\"type\": \"schema_registry\", \"url\": \"http://schema-registry:8081\"}, \"flattenSpec\": {...}}","handlingStrategy":"validation","validationCode":"// Validate inputFormat spec before submission\nfinal Object decoder = inputFormat.get(\"avroBytesDecoder\");\nif (decoder == null || ((Map<String,Object>) decoder).get(\"type\") == null) {\n  throw new IllegalArgumentException(\"avroBytesDecoder with a valid type is required for the avro inputFormat\");\n}","typeGuard":"boolean hasAvroBytesDecoder(Map<String,Object> inputFormat) {\n  return inputFormat.get(\"avroBytesDecoder\") instanceof Map\n      && ((Map<?,?>) inputFormat.get(\"avroBytesDecoder\")).get(\"type\") instanceof String;\n}","tryCatchPattern":"try {\n  new AvroStreamInputFormat(flattenSpec, decoder, binaryAsString, extractUnionsByType);\n} catch (IllegalArgumentException e) {\n  // surface a spec-validation error naming the missing avroBytesDecoder before runtime\n}","preventionTips":["Always include avroBytesDecoder with a correct \"type\" (schema_registry, inline_schema, multiple_schemas) in avro inputFormats.","Double-check the decoder type spelling; a typo makes Jackson bind null.","Validate ingestion specs with a linter/test-submit before production."],"tags":["java","avro","input-format","missing-config"],"backgroundTag":"missing-required-config-field","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}