apache/flink · error · UTFDataFormatException
malformed input: partial character at end
Error message
malformed input: partial character at end
What it means
Thrown as a UTFDataFormatException by AbstractPagedInputView's modified-UTF-8 reader when a two-byte sequence (lead byte 0b110xxxxx) is started but the stream ends before the continuation byte can be read (count exceeds utflen). This means a multi-byte UTF-8 character was split at the boundary of the declared UTF length, indicating truncation or corruption of the string payload.
Source
Thrown at flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java:462
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
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)) {View on GitHub (pinned to 2f3c205e92)
Solutions
- Verify the string was written with the matching writeUTF and the length prefix is correct.
- Ensure the underlying data is not truncated — check total byte count against expected.
- Avoid manual construction of modified-UTF-8 byte arrays; use the provided writeUTF/readUTF pair.
- If data corruption is systemic, regenerate the checkpoint/savepoint from a known-good source.
Defensive patterns
Strategy: try-catch
Try / catch
try {
String s = inputView.readUTF();
} catch (UTFDataFormatException e) {
// truncated multi-byte character; verify data integrity
} Prevention
- Always pair writeUTF with readUTF.
- Do not manually construct modified-UTF-8 byte arrays.
- Ensure string data is not truncated in storage.
When it happens
Trigger: Reading a UTF string via readUTF() where the declared utflen is too short to contain the full multi-byte character at the end; truncation of the byte array mid-character; corruption of the length prefix.
Common situations: Truncated string data in serialized records; inconsistent write/read of UTF length prefixes; segment boundary splits corrupting the character.
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 around byte {}
- 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/ef3af0ce19c498a4.
Report an issue: GitHub.