{"record":{"id":"bdb76037f6e3726a","repo":"kestra-io/kestra","slug":"illegal-type-path-e-getmessage","errorCode":null,"errorMessage":"Illegal {type} path:{e.getMessage()}","messagePattern":"Illegal (.+?) path:(.+?)","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/serializers/YamlParser.java","lineNumber":69,"sourceCode":"            if (e.getCause() instanceof JsonProcessingException jsonProcessingException) {\n                throw toConstraintViolationException(input, type(cls), jsonProcessingException);\n            }\n\n            throw e;\n        }\n    }\n\n    private static <T> String type(Class<T> cls) {\n        return cls.getSimpleName().toLowerCase();\n    }\n\n    public static <T> T parse(File file, Class<T> cls) throws ConstraintViolationException {\n        try {\n            String input = IOUtils.toString(file.toURI(), StandardCharsets.UTF_8);\n            return read(input, cls, type(cls));\n\n        } catch (IOException e) {\n            throw new ConstraintViolationException(\n                \"Illegal \" + type(cls) + \" path:\" + e.getMessage(),\n                Collections.singleton(\n                    ManualConstraintViolation.of(\n                        e.getMessage(),\n                        file,\n                        File.class,\n                        type(cls),\n                        file.getAbsolutePath()\n                    )\n                )\n            );\n        }\n    }\n\n    private static <T> T read(String input, Class<T> objectClass, String resource) {\n        try {\n            return STRICT_MAPPER.readValue(input, objectClass);\n        } catch (JsonProcessingException e) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/serializers/YamlParser.java#L51-L87","documentation":"The `YamlParser.parse(File, Class)` method reads a file's contents via `IOUtils.toString(file.toURI())`. If an `IOException` occurs (file not found, permission denied, unreadable, invalid path), it is caught and re-thrown as a `ConstraintViolationException` with the message 'Illegal {type} path:{detail}'. The `{type}` is the lowercased simple class name (e.g. 'flow', 'template').","triggerScenarios":"Calling `YamlParser.parse(file, Flow.class)` on a file path that does not exist. The file exists but the process lacks read permissions. The path is a directory, not a file. The URI is malformed.","commonSituations":"A plugin or test loads a flow YAML from a relative path that resolves incorrectly. A file was deleted between listing and parsing. A CI environment mounts files with restricted permissions.","solutions":["Verify the file exists at the given absolute path before calling parse.","Check file read permissions for the running process.","Use an absolute path rather than a relative one to avoid working-directory ambiguity.","If loading from resources, ensure the resource is packaged correctly (e.g., in the JAR)."],"exampleFix":"// before\nFlow flow = YamlParser.parse(new File(\"flows/myflow.yml\"), Flow.class);\n// after\nFile file = new File(\"flows/myflow.yml\");\nif (!file.exists() || !file.canRead()) {\n    throw new IllegalStateException(\"Cannot read flow file: \" + file.getAbsolutePath());\n}\nFlow flow = YamlParser.parse(file, Flow.class);","handlingStrategy":"validation","validationCode":"// Validate file exists and is readable before parsing\nimport java.io.File;\n\npublic static void validateYamlFile(File file) {\n    Objects.requireNonNull(file, \"file cannot be null\");\n    if (!file.exists()) {\n        throw new IllegalArgumentException(\"File does not exist: \" + file.getAbsolutePath());\n    }\n    if (!file.isFile()) {\n        throw new IllegalArgumentException(\"Path is not a file: \" + file.getAbsolutePath());\n    }\n    if (!file.canRead()) {\n        throw new IllegalArgumentException(\"Cannot read file: \" + file.getAbsolutePath());\n    }\n}","typeGuard":"import { existsSync, statSync, constants } from 'fs';\n\nfunction isReadableFile(path: string): boolean {\n    try {\n        const stat = statSync(path);\n        return stat.isFile();\n    } catch {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    Flow flow = YamlParser.parse(file, Flow.class);\n} catch (ConstraintViolationException e) {\n    if (e.getMessage().startsWith(\"Illegal flow path:\") || e.getMessage().startsWith(\"Illegal template path:\")) {\n        log.error(\"Could not read YAML file {}: {}\", file.getAbsolutePath(), e.getMessage());\n        // handle missing/unreadable file\n    } else {\n        throw e; // re-throw YAML content errors\n    }\n}","preventionTips":["Always check file existence and readability before parsing.","Use absolute paths to avoid working-directory ambiguity.","In tests, verify test resource files are in `src/test/resources/` and packaged correctly.","Log the resolved absolute path when a file-read error occurs to aid debugging."],"tags":["yaml","parser","io","file-not-found","constraint-violation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}