apache/flink · error · UTFDataFormatException
malformed input around byte {}
Error message
malformed input around byte {} What it means
Thrown as a UTFDataFormatException by AbstractPagedInputView's modified-UTF-8 reader when a two-byte sequence (lead byte 0b110xxxxx) is followed by a byte that is NOT a valid continuation byte (does not match 0b10xxxxxx, i.e. (char2 & 0xC0) != 0x80). This indicates the second byte of the character is malformed, signalling byte-level corruption rather than truncation.
Source
Thrown at flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java:467
case 4:
case 5:
case 6:
case 7:
/* 0xxxxxxx */
count++;
chararr[chararrCount++] = (char) c;
break;
case 12:
case 13:
/* 110x xxxx 10xx xxxx */
count += 2;
if (count > utflen) {
throw new UTFDataFormatException(
"malformed input: partial character at end");
}
char2 = (int) bytearr[count - 1];
if ((char2 & 0xC0) != 0x80) {
throw new UTFDataFormatException("malformed input around byte " + count);
}
chararr[chararrCount++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
/* 1110 xxxx 10xx xxxx 10xx xxxx */
count += 3;
if (count > utflen) {
throw new UTFDataFormatException(
"malformed input: partial character at end");
}
char2 = (int) bytearr[count - 2];
char3 = (int) bytearr[count - 1];
if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
throw new UTFDataFormatException(
"malformed input around byte " + (count - 1));
}
chararr[chararrCount++] =
(char)View on GitHub (pinned to 2f3c205e92)
Solutions
- Confirm the data was written using Java modified UTF-8 (writeUTF), not standard UTF-8.
- Run an integrity check on the underlying storage for the affected file.
- Regenerate the state from a valid checkpoint/savepoint.
- If interoperating with external systems, convert standard UTF-8 to modified UTF-8 or use a byte-based string serialization.
Defensive patterns
Strategy: try-catch
Try / catch
try {
String s = inputView.readUTF();
} catch (UTFDataFormatException e) {
// malformed continuation byte; check for encoding mismatch or storage corruption
} Prevention
- Confirm data uses Java modified UTF-8, not standard UTF-8.
- Run storage integrity checks on checkpoint files.
- Avoid feeding externally-encoded UTF-8 to readUTF.
When it happens
Trigger: Reading a UTF string where a two-byte character's continuation byte is corrupted or missing its 0x80 mask; feeding non-UTF-8 bytes to readUTF; byte-level flipping or overwrite in the serialized payload.
Common situations: Bit-rot or storage corruption in checkpoint files; incorrect encoding (e.g. standard UTF-8 vs Java modified UTF-8 mismatch); buffer overwrites clobbering character bytes.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- malformed input: partial character at end
- There is no enough data left in the DataInputView.
- encoded string too long: {} memory
- Initial Segment may not be null
- Encoded string reached maximum length: {utflen}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/a7a52b3be80cfe22.
Report an issue: GitHub.