{"record":{"id":"6f30fc55bdc8b34d","repo":"apache/iceberg","slug":"malformed-input-around-byte-6f30fc","errorCode":null,"errorMessage":"malformed input around byte ","messagePattern":"malformed input around byte ","errorType":"exception","errorClass":"UTFDataFormatException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/util/SerializerHelper.java","lineNumber":151,"sourceCode":"          if (count > utflen) {\n            throw new UTFDataFormatException(\"malformed input: partial character at end\");\n          }\n          char2 = bytearr[count - 1];\n          if ((char2 & 0xC0) != 0x80) {\n            throw new UTFDataFormatException(\"malformed input around byte \" + count);\n          }\n          chararr[chararrCount++] = (char) (((ch & 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(\"malformed input: partial character at end\");\n          }\n          char2 = bytearr[count - 2];\n          char3 = bytearr[count - 1];\n          if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {\n            throw new UTFDataFormatException(\"malformed input around byte \" + (count - 1));\n          }\n          chararr[chararrCount++] =\n              (char) (((ch & 0x0F) << 12) | ((char2 & 0x3F) << 6) | (char3 & 0x3F));\n          break;\n        default:\n          /* 10xx xxxx, 1111 xxxx */\n          throw new UTFDataFormatException(\"malformed input around byte \" + count);\n      }\n    }\n    // The number of chars produced may be less than utflen\n    return new String(chararr, 0, chararrCount);\n  }\n\n  private static int getUTFBytesSize(int ch) {\n    if ((ch >= 0x0001) && (ch <= 0x007F)) {\n      return 1;\n    } else if (ch > 0x07FF) {\n      return 3;","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/util/SerializerHelper.java#L133-L169","documentation":"When decoding a 3-byte modified UTF-8 sequence in readLongUTF, both continuation bytes must match the 10xxxxxx pattern. If either byte fails the check, the decoder throws UTFDataFormatException reporting the byte offset (count - 1). Note the message ends with the offset number appended at runtime.","triggerScenarios":"Reading a stream where byte 2 or 3 of a 3-byte sequence is not a valid continuation byte — invalid encoded data from an incompatible or corrupt source.","commonSituations":"Binary data passed as strings; bytes written by a different UTF encoding (e.g. standard UTF-8 with 4-byte sequences, CESU-8 mismatch); corrupted state.","solutions":["Verify writer and reader share the exact same modified-UTF-8 encoding","Use byte[] fields instead of strings for binary data","Validate payload encoding before serialization","Restore from a valid checkpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return SerializerHelper.readLongUTF(in);\n} catch (UTFDataFormatException e) {\n  throw new IOException(\"malformed UTF sequence: \" + e.getMessage(), e);\n}","preventionTips":["Use binary fields for non-text data","Confirm the producing side used the same modified UTF-8 encoder"],"tags":["flink","serialization","utf","malformed-input"],"backgroundTag":"json-parse-error","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}