{"record":{"id":"ef3af0ce19c498a4","repo":"apache/flink","slug":"malformed-input-partial-character-at-end","errorCode":null,"errorMessage":"malformed input: partial character at end","messagePattern":"malformed input: partial character at end","errorType":"exception","errorClass":"UTFDataFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java","lineNumber":462,"sourceCode":"            switch (c >> 4) {\n                case 0:\n                case 1:\n                case 2:\n                case 3:\n                case 4:\n                case 5:\n                case 6:\n                case 7:\n                    /* 0xxxxxxx */\n                    count++;\n                    chararr[chararrCount++] = (char) c;\n                    break;\n                case 12:\n                case 13:\n                    /* 110x xxxx 10xx xxxx */\n                    count += 2;\n                    if (count > utflen) {\n                        throw new UTFDataFormatException(\n                                \"malformed input: partial character at end\");\n                    }\n                    char2 = (int) bytearr[count - 1];\n                    if ((char2 & 0xC0) != 0x80) {\n                        throw new UTFDataFormatException(\"malformed input around byte \" + count);\n                    }\n                    chararr[chararrCount++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F));\n                    break;\n                case 14:\n                    /* 1110 xxxx 10xx xxxx 10xx xxxx */\n                    count += 3;\n                    if (count > utflen) {\n                        throw new UTFDataFormatException(\n                                \"malformed input: partial character at end\");\n                    }\n                    char2 = (int) bytearr[count - 2];\n                    char3 = (int) bytearr[count - 1];\n                    if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java#L444-L480","documentation":"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.","triggerScenarios":"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.","commonSituations":"Truncated string data in serialized records; inconsistent write/read of UTF length prefixes; segment boundary splits corrupting the character.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String s = inputView.readUTF();\n} catch (UTFDataFormatException e) {\n    // truncated multi-byte character; verify data integrity\n}","preventionTips":["Always pair writeUTF with readUTF.","Do not manually construct modified-UTF-8 byte arrays.","Ensure string data is not truncated in storage."],"tags":["memory","paged-io","utf-8","data-corruption"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}