{"record":{"id":"569d0392dede4bf6","repo":"apache/seatunnel","slug":"python-working-directory-is-not-a-directory","errorCode":null,"errorMessage":"python.working.directory is not a directory: {}","messagePattern":"python\\.working\\.directory is not a directory: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-python/src/main/java/org/apache/seatunnel/connectors/seatunnel/python/source/PythonSourceReader.java","lineNumber":309,"sourceCode":"        }\n    }\n\n    private Path validateScriptPath() {\n        Path scriptPath = Paths.get(sourceConfig.getPythonScriptPath());\n        if (!Files.isRegularFile(scriptPath)) {\n            throw new IllegalArgumentException(\n                    \"python.script.path does not point to a readable file: \" + scriptPath);\n        }\n        return scriptPath;\n    }\n\n    private void configureWorkingDirectory(ProcessBuilder processBuilder, Path scriptPath) {\n        String workingDirectory = sourceConfig.getPythonWorkingDirectory();\n        Path processDirectory;\n        if (workingDirectory != null && !workingDirectory.trim().isEmpty()) {\n            processDirectory = Paths.get(workingDirectory);\n            if (!Files.isDirectory(processDirectory)) {\n                throw new IllegalArgumentException(\n                        \"python.working.directory is not a directory: \" + processDirectory);\n            }\n        } else {\n            processDirectory = scriptPath.toAbsolutePath().getParent();\n        }\n\n        if (processDirectory != null) {\n            processBuilder.directory(processDirectory.toFile());\n        }\n    }\n\n    /**\n     * Starts a bounded background write so a script that ignores stdin cannot block open forever.\n     */\n    private void startStdinWriter(Map<String, Object> scriptConfig) {\n        stdinWriterThread =\n                new Thread(\n                        () -> {","sourceCodeStart":291,"sourceCodeEnd":327,"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#L291-L327","documentation":"PythonSourceReader launches a Python child process and optionally sets its working directory from the 'python.working.directory' config option. When that option is set but the path does not exist on disk or resolves to a regular file rather than a directory, the reader refuses to start and throws this IllegalArgumentException during open(). It is a fail-fast config validation so the process is never spawned with a bogus cwd.","triggerScenarios":"Setting 'python.working.directory' to a path that does not exist, or to a file instead of a directory, then calling open() on the Python source (configureWorkingDirectory).","commonSituations":"Typo in the path; relative path resolved against a different working directory than the job run directory; path points at a script file instead of its folder; directory deleted after config was written; Docker/K8s container where the mount is missing.","solutions":["Fix 'python.working.directory' to point to an existing directory","Create the directory (mkdir -p) before submitting the job","Use an absolute path to avoid surprises from the engine's working directory","Remove the option entirely to default to the script's parent directory"],"exampleFix":"// before\npython.working.directory = /opt/jobs/python-script.py\n// after\npython.working.directory = /opt/jobs","handlingStrategy":"validation","validationCode":"Path wd = Paths.get(config.getPythonWorkingDirectory());\nif (!Files.isDirectory(wd)) {\n    throw new IllegalArgumentException(\"python.working.directory is not a directory: \" + wd);\n}","typeGuard":null,"tryCatchPattern":"try {\n    reader.open();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"python.working.directory\")) {\n        // fix config and revalidate before retry\n    }\n}","preventionTips":["Validate python.working.directory exists and is a directory at job-submission time","Use absolute paths in configs","Mount required directories in containers before job start"],"tags":["config","filesystem","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}