{"record":{"id":"bd8601d9d07883a4","repo":"kestra-io/kestra","slug":"output-file-s-contains-unsupported-characters","errorCode":null,"errorMessage":"Output file '%s' contains unsupported characters. Allowed: letters, digits, hyphens, dots, underscores, plus, tilde, hash, equals, slashes, commas, colons, semicolons.","messagePattern":"Output file '(.+?)' contains unsupported characters\\. Allowed: letters, digits, hyphens, dots, underscores, plus, tilde, hash, equals, slashes, commas, colons, semicolons\\.","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/models/tasks/runners/ScriptService.java","lineNumber":155,"sourceCode":"                .filter(path -> !path.startsWith(\".\"))\n                .forEach(throwConsumer(path ->\n                {\n                    String filename = outputDir.relativize(path).toString();\n                    validateStoragePath(filename);\n\n                    uploaded.put(\n                        filename,\n                        runContext.storage().putFile(path.toFile(), filename)\n                    );\n                }));\n        }\n\n        return uploaded;\n    }\n\n    static void validateStoragePath(String filename) throws IOException {\n        if (!VALID_STORAGE_PATH_PATTERN.matcher(filename).matches()) {\n            throw new IOException(\n                \"Output file '%s' contains unsupported characters. Allowed: letters, digits, hyphens, dots, underscores, plus, tilde, hash, equals, slashes, commas, colons, semicolons.\"\n                    .formatted(filename)\n            );\n        }\n    }\n\n    public static List<String> scriptCommands(List<String> interpreter, List<String> beforeCommands, String command) {\n        return scriptCommands(interpreter, beforeCommands, List.of(command), TargetOS.LINUX);\n    }\n\n    public static List<String> scriptCommands(List<String> interpreter, List<String> beforeCommands, List<String> commands) {\n        return scriptCommands(interpreter, beforeCommands, commands, TargetOS.LINUX);\n    }\n\n    public static List<String> scriptCommands(List<String> interpreter, List<String> beforeCommands, String command, TargetOS targetOS) {\n        return scriptCommands(interpreter, beforeCommands, List.of(command), targetOS);\n    }\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/models/tasks/runners/ScriptService.java#L137-L173","documentation":"Thrown by ScriptService.validateStoragePath() when an output file's relative path does not match VALID_STORAGE_PATH_PATTERN. The pattern restricts filenames to letters, digits, hyphens, dots, underscores, plus, tilde, hash, equals, slashes, commas, colons, and semicolons. Any other character (spaces, parentheses, Unicode, etc.) is rejected because internal storage keys must be URL-safe. This fires during uploadOutputFiles() before the file is persisted to object storage.","triggerScenarios":"An output file's name contains a space, parenthesis, exclamation mark, or any non-ASCII character; a script writes a file like 'result (1).csv' or 'café.txt'; a generated filename includes an ampersand or question mark.","commonSituations":"User-named output files with spaces or special characters; localized filenames; shell redirection producing unexpected names.","solutions":["Sanitize output filenames to use only the allowed character set before writing.","Replace spaces with underscores or hyphens.","If Unicode is required, transliterate to ASCII or encode the name."],"exampleFix":"# before\nscript writes: 'result (1).csv'\n# IOException: unsupported characters\n\n# after\nscript writes: 'result_1.csv'","handlingStrategy":"validation","validationCode":"// VALID_STORAGE_PATH_PATTERN must allow only: [A-Za-z0-9.\\-_+~#=/,;:]\nprivate static final Pattern ALLOWED = Pattern.compile(\"[A-Za-z0-9.\\\\-_+~#=/,;:]+\");\nif (!ALLOWED.matcher(filename).matches()) {\n    throw new IOException(\"Output file contains unsupported characters: \" + filename);\n}","typeGuard":"const ALLOWED = /^[A-Za-z0-9.\\-_+~#=/,;:]+$/;\nfunction isSafeStorageName(name: string): boolean { return ALLOWED.test(name); }","tryCatchPattern":"try {\n    ScriptService.uploadOutputFiles(runContext, outputDir);\n} catch (IOException e) {\n    log.error(\"Output filename rejected: {}\", e.getMessage());\n}","preventionTips":["Sanitize generated filenames to ASCII alphanumerics and allowed punctuation.","Replace spaces and parentheses with underscores before writing output files."],"tags":["script","validation","storage","filename","output-files"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}