{"record":{"id":"e7b359f2268b508b","repo":"apache/flink","slug":"failed-to-deserialize-json-s","errorCode":null,"errorMessage":"Failed to deserialize JSON '%s'.","messagePattern":"Failed to deserialize JSON '(.+?)'\\.","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonParserRowDataDeserializationSchema.java","lineNumber":100,"sourceCode":"            /* First: must point to a token; if not pointing to one, advance.\n             * This occurs before first read from JsonParser, as well as\n             * after clearing of current token.\n             */\n            if (root.currentToken() == null) {\n                root.nextToken();\n            }\n            if (root.currentToken() != JsonToken.START_OBJECT\n                    && root.currentToken() != JsonToken.START_ARRAY) {\n                throw JsonMappingException.from(root, \"No content to map due to end-of-input\");\n            }\n            if (root.currentToken() == JsonToken.START_ARRAY) {\n                processArray(root, out);\n            } else {\n                processObject(root, out);\n            }\n        } catch (Throwable t) {\n            if (!ignoreParseErrors) {\n                throw new IOException(\n                        format(\"Failed to deserialize JSON '%s'.\", new String(message)), t);\n            }\n            logParseErrorIfDebugEnabled(message, t);\n        }\n    }\n\n    private void processArray(JsonParser root, Collector<RowData> out) throws IOException {\n        while (root.nextToken() != JsonToken.END_ARRAY) {\n            out.collect((RowData) runtimeConverter.convert(root));\n        }\n    }\n\n    private void processObject(JsonParser root, Collector<RowData> out) throws IOException {\n        out.collect((RowData) runtimeConverter.convert(root));\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonParserRowDataDeserializationSchema.java#L82-L117","documentation":"IOException thrown by JsonParserRowDataDeserializationSchema.deserialize(byte[], Collector) when parsing/conversion fails and ignoreParseErrors is false. The original Throwable is attached as the cause; the message embeds the raw payload. This is the standard 'bad JSON record fails the job' error for the streaming JSON parser schema.","triggerScenarios":"Malformed JSON (truncated bytes, not an object/array at root, 'No content to map due to end-of-input'), or well-formed JSON whose values do not match the declared column types (string where int expected, out-of-range numbers), with 'json.ignore-parse-errors'='false' (default).","commonSituations":"Kafka messages split across records or binary garbage; upstream producers changing schemas without notice; charsets other than UTF-8; strict schemas hitting optional fields with wrong types.","solutions":["Inspect the embedded payload and the cause in the stack trace to see whether it is syntax or type mismatch","Fix the producer/schema mismatch (correct column types in DDL to match real data)","If dirty records are acceptable to drop, set 'json.ignore-parse-errors'='true' (then bad rows are skipped, and only logged in DEBUG)","For truncation issues, verify the source's max message size / fetch settings"],"exampleFix":"-- before\n'json.ignore-parse-errors' = 'false'\n\n-- after (tolerate dirty records; note: they are silently dropped)\n'json.ignore-parse-errors' = 'true'","handlingStrategy":"fallback","validationCode":"// sample-validate before full ingestion (dev only):\ntry (JsonParser p = new JsonFactory().createParser(sampleBytes)) {\n    p.nextToken(); // throws on truncated/non-JSON\n}","typeGuard":null,"tryCatchPattern":"catch (IOException e) {\n    if (ignoreParseErrors) { /* row already skipped */ }\n    else { log.error(\"bad record: {}\", e.getMessage()); /* dead-letter it */ }\n}","preventionTips":["Set 'json.ignore-parse-errors'='true' only if dropping bad rows is acceptable; otherwise add a dead-letter path","Contract-test the producer schema against the DDL in CI","Watch for truncated messages at the source (max.request/fetch sizes)"],"tags":["flink","json","deserialization","kafka","data-quality"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}