{"record":{"id":"a4ea513b6da2be51","repo":"prestodb/presto","slug":"generic-internal-error-a4ea51","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"No avro record found","messagePattern":"No avro record found","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/avro/AvroRowDecoder.java","lineNumber":65,"sourceCode":"                .collect(toImmutableMap(identity(), this::createColumnDecoder));\n    }\n\n    private AvroColumnDecoder createColumnDecoder(DecoderColumnHandle columnHandle)\n    {\n        return new AvroColumnDecoder(columnHandle);\n    }\n\n    @Override\n    public Optional<Map<DecoderColumnHandle, FieldValueProvider>> decodeRow(byte[] data, Map<String, String> dataMap)\n    {\n        GenericRecord avroRecord;\n        DataFileStream<GenericRecord> dataFileReader = null;\n        try {\n            // Assumes producer uses DataFileWriter or data comes in this particular format.\n            // TODO: Support other forms for producers\n            dataFileReader = new DataFileStream<>(new ByteArrayInputStream(data), avroRecordReader);\n            if (!dataFileReader.hasNext()) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"No avro record found\");\n            }\n            avroRecord = dataFileReader.next();\n            if (dataFileReader.hasNext()) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Unexpected extra record found\");\n            }\n        }\n        catch (Exception e) {\n            throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Decoding Avro record failed.\", e);\n        }\n        finally {\n            closeQuietly(dataFileReader);\n        }\n\n        return Optional.of(columnDecoders.entrySet().stream()\n                .collect(toImmutableMap(\n                        Map.Entry::getKey,\n                        entry -> entry.getValue().decodeField(avroRecord))));\n    }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/avro/AvroRowDecoder.java#L47-L83","documentation":"AvroRowDecoder.decodeRow wraps the raw Avro bytes in a DataFileStream and expects exactly one GenericRecord. This GENERIC_INTERNAL_ERROR is thrown when the stream is a valid Avro container but contains zero records, meaning the payload has only a schema header and no data. The decoder treats an empty record stream as a protocol violation it cannot recover from.","triggerScenarios":"Kafka message payload contains a valid Avro DataFile header but no records (empty container); producer wrote a file with zero rows; payload truncated to just the header portion.","commonSituations":"Producer misconfiguration emitting empty Avro files; a heartbeat/no-op message serialized as an empty container; truncation or corruption dropping the record block while keeping the header; producer switching formats mid-topic so old consumers see empty streams.","solutions":["Inspect the raw payload bytes and confirm the producer is actually writing a record, not an empty DataFileWriter output","Verify the producer-side Avro serialization path (DataFileWriter append + flush/close) actually writes the record before committing","Check for message truncation or corruption between producer and consumer (broker retention, max message size, proxy buffering)","If empty payloads are legitimate in your pipeline, filter them before calling decodeRow instead of routing them to the decoder"],"exampleFix":"// before (producer): DataFileWriter created but record appended conditionally, file closed with 0 records\n// after (producer):\nif (record != null) {\n    writer.append(record);\n}\nwriter.close();\n// consumer side: skip empty payloads before decode\nif (data == null || data.length == 0) { return Optional.empty(); }","handlingStrategy":"validation","validationCode":"boolean isNonEmptyAvroContainer(byte[] data) {\n    return data != null && data.length > 4\n        && data[0]=='O' && data[1]=='b' && data[2]=='j' && data[3]==1;\n}","typeGuard":"boolean hasAtLeastOneRecord(byte[] data) throws IOException {\n    try (DataFileStream<GenericRecord> r =\n             new DataFileStream<>(new ByteArrayInputStream(data), new GenericDatumReader<>())) {\n        return r.hasNext();\n    }\n}","tryCatchPattern":"try { decoder.decodeRow(...) }\ncatch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"GENERIC_INTERNAL_ERROR\")) {\n        log.warn(\"Skipping empty/invalid avro payload\"); return Optional.empty();\n    }\n    throw e;\n}","preventionTips":["Check the Avro magic bytes (Obj\\u0001) before decoding","Enforce one-record-per-message on the producer side","Monitor producer serialization for zero-record files","Add payload-size sanity metrics to catch truncation"],"tags":["avro","kafka","decoding","data-corruption"],"backgroundTag":"avro-empty-record-stream","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}