{"record":{"id":"589cb4f1198b42c8","repo":"apache/seatunnel","slug":"fileconnectorerrorcode-data-deserialize-failed-589cb4","errorCode":"FileConnectorErrorCode.DATA_DESERIALIZE_FAILED","errorMessage":"Deserialize this jsonFile data [%s] failed, please check the origin data","messagePattern":"Deserialize this jsonFile data \\[(.+?)\\] failed, please check the origin data","errorType":"error_code","errorClass":"FileConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/JsonReadStrategy.java","lineNumber":141,"sourceCode":"                            line -> {\n                                try {\n                                    SeaTunnelRow seaTunnelRow =\n                                            deserializationSchema.deserialize(\n                                                    line.getBytes(StandardCharsets.UTF_8));\n                                    if (isMergePartition) {\n                                        int index = seaTunnelRowType.getTotalFields();\n                                        for (String value : partitionsMap.values()) {\n                                            seaTunnelRow.setField(index++, value);\n                                        }\n                                    }\n                                    seaTunnelRow.setTableId(split.getTableId());\n                                    output.collect(seaTunnelRow);\n                                } catch (IOException e) {\n                                    String errorMsg =\n                                            String.format(\n                                                    \"Deserialize this jsonFile data [%s] failed, please check the origin data\",\n                                                    line);\n                                    throw new FileConnectorException(\n                                            FileConnectorErrorCode.DATA_DESERIALIZE_FAILED,\n                                            errorMsg,\n                                            e);\n                                }\n                            });\n        }\n    }\n\n    @Override\n    public SeaTunnelRowType getSeaTunnelRowTypeInfo(String path) throws FileConnectorException {\n        throw new FileConnectorException(\n                CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,\n                \"User must defined schema for json file type\");\n    }\n}\n","sourceCodeStart":123,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/JsonReadStrategy.java#L123-L157","documentation":"The JSON file read strategy failed to deserialize a line of a JSON file into a SeaTunnelRow, wrapping the underlying IOException. SeaTunnel throws this because the origin data in the JSON file does not conform to the schema the user defined in the config. The failing line's raw text is included in the message for inspection.","triggerScenarios":"JsonReadStrategy.readProcess() calls the deserializer for each line inside a row-output collector; any IOException while parsing a line (malformed JSON, field type mismatch against the configured schema, missing required field) throws FileConnectorException(DATA_DESERIALIZE_FAILED).","commonSituations":"JSON files with trailing commas or concatenated (non-newline-delimited) JSON objects; values whose type differs from the user-defined schema (e.g. string where int declared); empty/corrupt lines from a truncated upload; files written with a different schema than schema { fields { ... } }.","solutions":["Open the file and inspect the offending line printed in the error message; fix or remove the malformed record.","Validate each line parses as JSON (e.g. jq) before running the job.","Check the user-defined schema matches the actual JSON field names and types, and correct schema in the source config.","If files are multi-line pretty-printed JSON, convert them to JSON Lines (one object per line).","Pre-clean or filter dirty records upstream before the file source."],"exampleFix":"// before: schema declares id as int but file line is {\"id\":\"abc\"}\nschema = {\n  fields {\n    id = int\n    name = string\n  }\n}\n// after: align schema with real data or fix the data\n// data: {\"id\":1,\"name\":\"abc\"}","handlingStrategy":"validation","validationCode":"// validate every line before running the job\nfor line in file.lines: JSON.parse(line) // or: jq -c . file.json > /dev/null","typeGuard":"function isValidJsonLine(line) { try { const o = JSON.parse(line); return o && typeof o === 'object'; } catch { return false; } }","tryCatchPattern":"try { reader.read(); } catch (FileConnectorException e) { if (e.getCode() == FileConnectorErrorCode.DATA_DESERIALIZE_FAILED) { log.error(\"Bad JSON line: {}\", extractLine(e.getMessage())); skipOrQuarantine(); } else { throw e; } }","preventionTips":["Ensure JSON files are JSON Lines format (one object per line)","Validate source files with jq or a schema validator before job submission","Keep the configured schema in sync with the upstream writer's contract","Add a pre-job data quality check on sample files"],"tags":["json","file-source","deserialization","data-quality"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}