{"record":{"id":"d116e0eb0c117bae","repo":"apache/seatunnel","slug":"failed-to-deserialize-python-source-stdout-line","errorCode":null,"errorMessage":"Failed to deserialize python source stdout line [{}]","messagePattern":"Failed to deserialize python source stdout line \\[(.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-python/src/main/java/org/apache/seatunnel/connectors/seatunnel/python/source/PythonSourceReader.java","lineNumber":461,"sourceCode":"                        \"python-source-stdout-pump\");\n        stdoutPumpThread.setDaemon(true);\n        stdoutPumpThread.start();\n    }\n\n    private void offerStdoutLine(String line) throws InterruptedException {\n        while (!closeRequested) {\n            if (stdoutLines.offer(line, QUEUE_OFFER_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {\n                return;\n            }\n        }\n    }\n\n    private void emitRow(String line, Collector<SeaTunnelRow> output) throws IOException {\n        SeaTunnelRow row;\n        try {\n            row = deserializationSchema.deserialize(line.getBytes(StandardCharsets.UTF_8));\n        } catch (Exception e) {\n            throw new IOException(\n                    \"Failed to deserialize python source stdout line [\" + line + \"]\", e);\n        }\n\n        if (row != null) {\n            output.collect(row);\n        }\n    }\n\n    private void finishIfProcessCompleted() throws Exception {\n        if (closeRequested || processExitVerified) {\n            return;\n        }\n\n        if (process.isAlive()) {\n            return;\n        }\n\n        if (!verifyProcessExit()) {","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-python/src/main/java/org/apache/seatunnel/connectors/seatunnel/python/source/PythonSourceReader.java#L443-L479","documentation":"Each stdout line from the Python child is fed to the configured DeserializationSchema to produce a SeaTunnelRow. If deserialization throws for a given line, the reader wraps it in an IOException naming the offending line, failing the task rather than silently dropping data.","triggerScenarios":"The Python script prints a line that the DeserializationSchema cannot parse — wrong JSON structure, non-UTF8-safe control characters, partial/truncated line, debug print statements mixed into stdout, or a schema/type change on the Python side.","commonSituations":"Script prints logs or banners to stdout instead of stderr; Python emits JSON with fields/types that don't match the declared SeaTunnel schema; script output truncated on crash mid-line; version drift between script output format and job schema.","solutions":["Move all logging/debug prints in the Python script to stderr","Print exactly one JSON object per row, matching the declared schema","Validate a sample output line with the same deserializer locally","Check the offending line in the message for schema mismatches"],"exampleFix":"# before\nprint('loaded model')\nprint(json.dumps(row))\n# after\nprint('loaded model', file=sys.stderr)\nprint(json.dumps(row))","handlingStrategy":"try-catch","validationCode":"import json\nline = get_sample_stdout_line()\njson.loads(line)  # must succeed and match the declared SeaTunnel schema","typeGuard":null,"tryCatchPattern":"try {\n    reader.pollNext(output);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Failed to deserialize python source stdout line\")) {\n        // offending line is in e.getMessage(); fix script output or schema\n    }\n}","preventionTips":["Print only row JSON to stdout; send logs to stderr","Emit one JSON object per line with schema-matching fields/types","Add a schema round-trip test between script output and the DeserializationSchema"],"tags":["deserialization","json","python","stdout"],"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"}