{"record":{"id":"a7a52b3be80cfe22","repo":"apache/flink","slug":"malformed-input-around-byte","errorCode":null,"errorMessage":"malformed input around byte {}","messagePattern":"malformed input around byte (.+?)","errorType":"exception","errorClass":"UTFDataFormatException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java","lineNumber":467,"sourceCode":"                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)) {\n                        throw new UTFDataFormatException(\n                                \"malformed input around byte \" + (count - 1));\n                    }\n                    chararr[chararrCount++] =\n                            (char)","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/memory/AbstractPagedInputView.java#L449-L485","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String s = inputView.readUTF();\n} catch (UTFDataFormatException e) {\n    // malformed continuation byte; check for encoding mismatch or storage corruption\n}","preventionTips":["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."],"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"}