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

  1. Confirm the data was written using Java modified UTF-8 (writeUTF), not standard UTF-8.
  2. Run an integrity check on the underlying storage for the affected file.
  3. Regenerate the state from a valid checkpoint/savepoint.
  4. 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

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

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/a7a52b3be80cfe22. Report an issue: GitHub.