{"record":{"id":"6547a078679694ca","repo":"apache/druid","slug":"failed-to-fetch-avro-schema-id-s-from-registry","errorCode":null,"errorMessage":"Failed to fetch Avro schema id[%s] from registry. Check if the schema exists in the registry. Otherwise it could mean that there is malformed data in the stream or data that doesn't conform to the schema specified.","messagePattern":"Failed to fetch Avro schema id\\[(.+?)\\] from registry\\. Check if the schema exists in the registry\\. Otherwise it could mean that there is malformed data in the stream or data that doesn't conform to the schema specified\\.","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java","lineNumber":143,"sourceCode":"  @Override\n  public GenericRecord parse(ByteBuffer bytes)\n  {\n    int length = bytes.limit() - 1 - 4;\n    if (length < 0) {\n      throw new ParseException(null, \"Failed to decode avro message, not enough bytes to decode (%s)\", bytes.limit());\n    }\n\n    bytes.get(); // ignore first \\0 byte\n    int id = bytes.getInt(); // extract schema registry id\n    int offset = bytes.position() + bytes.arrayOffset();\n    Schema schema;\n\n    try {\n      ParsedSchema parsedSchema = registry.getSchemaById(id);\n      schema = parsedSchema instanceof AvroSchema ? ((AvroSchema) parsedSchema).rawSchema() : null;\n    }\n    catch (IOException ex1) {\n      throw new ParseException(\n          null,\n          ex1,\n          \"Failed to fetch Avro schema id[%s] from registry. Check if the schema exists in the registry. Otherwise it\"\n          + \" could mean that there is malformed data in the stream or data that doesn't conform to the schema\"\n          + \" specified.\",\n          id\n      );\n    }\n    catch (RestClientException ex2) {\n      if (ex2.getErrorCode() == 401) {\n        throw new ParseException(\n            null,\n            ex2,\n            \"Failed to authenticate to schema registry for Avro schema id[%s]. Please check your credentials.\",\n            id\n        );\n      }\n      // For all other errors, just include the code and message received from the library.","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/avro-extensions/src/main/java/org/apache/druid/data/input/avro/SchemaRegistryBasedAvroBytesDecoder.java#L125-L161","documentation":"Thrown when IOException occurs while calling registry.getSchemaById(id) to fetch the Avro schema from the Confluent schema registry. Usually means the schema id does not exist in the registry, the registry is unreachable, or the stream contains malformed/nonconforming data.","triggerScenarios":"parse(ByteBuffer bytes) extracts a schema id from the wire-format header, then registry.getSchemaById(id) throws IOException — id not present in the target registry, wrong registry URL configured, or network failure.","commonSituations":"Pointing Druid at the wrong schema registry (different cluster/env); schema was deleted from the registry; topic data produced against a registry that was later rebuilt; DNS/network issues from Druid to the registry.","solutions":["Verify the schema id exists: curl http://<registry>/schemas/ids/<id>","Check the schema-registry URL and credentials in the AvroBytesDecoder inputFormat config","Confirm network connectivity from Druid processes to the schema registry host/port","Re-register missing schemas or repartition data produced with deleted schema ids"],"exampleFix":"// before\n\"avroBytesDecoder\": {\"type\": \"schema_registry\", \"schemaRegistryUrls\": [\"http://wrong-registry:8081\"]}\n// after\n\"avroBytesDecoder\": {\"type\": \"schema_registry\", \"schemaRegistryUrls\": [\"http://schema-registry:8081\"]}","handlingStrategy":"try-catch","validationCode":"// preflight: check registry reachability and schema existence\ncurl -f http://schema-registry:8081/schemas/ids/1 > /dev/null && echo OK || echo FAIL","typeGuard":null,"tryCatchPattern":"try {\n  GenericRecord record = decoder.parse(bytes);\n} catch (ParseException e) {\n  if (e.getMessage().startsWith(\"Failed to fetch Avro schema\")) {\n    LOG.error(e, \"Schema id missing/unreachable registry; pausing ingestion for ops check\");\n  }\n}","preventionTips":["Add schema-registry health checks to deployment readiness probes","Use the same registry instance as producers","Alert on 404 schema fetches to catch deleted schemas","Avoid rebuilding registries without exporting/importing existing schemas"],"tags":["avro","schema-registry","network"],"backgroundTag":"resource-not-found","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"}