{"record":{"id":"86fcbf08c7b030a8","repo":"risingwavelabs/risingwave","slug":"avro-parse-unexpected-eof","errorCode":null,"errorMessage":"avro parse unexpected eof","messagePattern":"avro parse unexpected eof","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/parser/avro/parser.rs","lineNumber":119,"sourceCode":"        // parse payload to avro value\n        // if use confluent schema, get writer schema from confluent schema registry\n        match &self.writer_schema_cache {\n            WriterSchemaCache::Confluent(resolver) => {\n                let (schema_id, mut raw_payload) = extract_schema_id(payload)?;\n                let writer_schema = resolver.get_by_id(schema_id).await?;\n                Ok(Some(from_avro_datum(\n                    writer_schema.as_ref(),\n                    &mut raw_payload,\n                    Some(&self.schema.original_schema),\n                )?))\n            }\n            WriterSchemaCache::File => {\n                // FIXME: we should not use `Reader` (file header) here. See comment above and https://github.com/risingwavelabs/risingwave/issues/12871\n                let mut reader = Reader::with_schema(&self.schema.original_schema, payload)?;\n                match reader.next() {\n                    Some(Ok(v)) => Ok(Some(v)),\n                    Some(Err(e)) => Err(e)?,\n                    None => bail!(\"avro parse unexpected eof\"),\n                }\n            }\n            WriterSchemaCache::Glue(resolver) => {\n                // <https://github.com/awslabs/aws-glue-schema-registry/blob/v1.1.20/common/src/main/java/com/amazonaws/services/schemaregistry/utils/AWSSchemaRegistryConstants.java#L59-L61>\n                // byte 0:      header version = 3\n                // byte 1:      compression: 0 = no compression; 5 = zlib (unsupported)\n                // byte 2..=17: 16-byte UUID as schema version id\n                // byte 18..:   raw avro payload\n                if payload.len() < 18 {\n                    bail!(\"payload shorter than 18-byte glue header\");\n                }\n                if payload[0] != 3 {\n                    bail!(\n                        \"Only support glue header version 3 but found {}\",\n                        payload[0]\n                    );\n                }\n                if payload[1] != 0 {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/parser/avro/parser.rs#L101-L137","documentation":"In the file-writer-schema avro parser path, the payload is decoded with apache-avro's Reader bound to the declared schema. If the iterator returns None, the buffer contained no decodable record — the payload was empty or exhausted. The parser bails with 'avro parse unexpected eof' instead of returning an empty record.","triggerScenarios":"Feeding an empty or truncated Avro message (with schema from file, i.e. schema.registry... file-based writer schema) to an Avro parser; the Reader cannot produce even one value from the payload.","commonSituations":"Producer wrote empty frames; message truncation during transport; schema/payload mismatch causing zero records to decode; misconfigured topic receiving non-Avro bytes.","solutions":["Verify the producer is emitting complete Avro records (check serialization on the producer side)","Inspect and fix the message size/truncation in the message queue","Confirm the payload actually matches the configured file schema","If using Confluent/Glue, ensure the correct schema-cache mode is configured rather than File"],"exampleFix":"// before\n// payload: empty byte array -> error\n// after: check upstream producer writes at least one record per message, or skip empty payloads in the producer","handlingStrategy":"validation","validationCode":"function validateAvroPayload(buf) {\n  if (!buf || buf.length === 0) throw new Error('empty avro payload; producer must serialize a record');\n}\n// call before producing to the topic consumed by RW","typeGuard":"function looksLikeAvroRecord(buf) {\n  return buf instanceof Uint8Array && buf.length > 0;\n}","tryCatchPattern":"match parser.parse(payload, _unused) {\n  Err(e) if e.to_string().contains(\"unexpected eof\") => {\n    warn!(\"skipping malformed/empty avro message\");\n  }\n  other => other?,\n}","preventionTips":["Verify producer-side Avro serialization writes full records","Monitor the source connector for malformed/truncated messages","Match the writer-schema cache mode (File/Confluent/Glue) to the actual producer setup"],"tags":["avro","parser","serialization","eof"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}