{"record":{"id":"caa98ec0d565b5b0","repo":"apache/iceberg","slug":"malformed-input-around-byte-count","errorCode":null,"errorMessage":"malformed input around byte {count}","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":138,"sourceCode":"        case 3:\n        case 4:\n        case 5:\n        case 6:\n        case 7:\n          /* 0xxxxxxx */\n          count++;\n          chararr[chararrCount++] = (char) ch;\n          break;\n        case 12:\n        case 13:\n          /* 110x xxxx 10xx xxxx */\n          count += 2;\n          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:","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/util/SerializerHelper.java#L120-L156","documentation":"During modified UTF-8 decoding in readLongUTF, a 2-byte sequence's second byte must be a continuation byte (10xxxxxx, i.e. & 0xC0 == 0x80). If it is not, the byte sequence is not valid modified UTF-8 and the decoder throws at the offending byte position.","triggerScenarios":"Reading a stream containing bytes that break the UTF-8 continuation-byte rule — e.g. random binary data interpreted as UTF, or strings written by an incompatible encoder.","commonSituations":"Deserializing data produced by a different serializer version; feeding binary blobs into string fields; corrupted state files.","solutions":["Ensure both writer and reader use SerializerHelper.writeLongUTF/readLongUTF symmetrically","Validate/clean input data to be valid UTF-8 before serializing","Use binary (byte[]) types instead of strings for non-text data","Recover data from a non-corrupted checkpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return SerializerHelper.readLongUTF(in);\n} catch (UTFDataFormatException e) {\n  LOG.error(\"malformed UTF data at {}\", e.getMessage(), e);\n  throw new IOException(\"invalid serialized string data\", e);\n}","preventionTips":["Never serialize raw binary as strings; use byte[] types","Keep writer/reader encoding symmetric","Validate input data encoding upstream"],"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-14T11:17:12.474Z"}