{"record":{"id":"0f6c41390bf7c029","repo":"kestra-io/kestra","slug":"file-type-not-allowed-accepted-extensions-allow","errorCode":null,"errorMessage":"File type not allowed. Accepted extensions: <allowedFileExtensions>","messagePattern":"File type not allowed\\. Accepted extensions: <allowedFileExtensions>","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/models/flows/input/FileInput.java","lineNumber":46,"sourceCode":"\n    /**\n     * Gets the file extension from the URI's path\n     */\n    private String getFileExtension(URI uri) {\n        String path = uri.getPath();\n        int lastDotIndex = path.lastIndexOf(\".\");\n        return lastDotIndex >= 0 ? path.substring(lastDotIndex).toLowerCase() : \"\";\n    }\n\n    @Override\n    public void validate(URI input) throws ConstraintViolationException {\n        if (input == null || allowedFileExtensions == null || allowedFileExtensions.isEmpty()) {\n            return;\n        }\n\n        String extension = getFileExtension(input);\n        if (!allowedFileExtensions.contains(extension.toLowerCase())) {\n            throw new ConstraintViolationException(\n                \"File type not allowed. Accepted extensions: \" + String.join(\", \", allowedFileExtensions),\n                Set.of()\n            );\n        }\n    }\n}\n","sourceCodeStart":28,"sourceCodeEnd":53,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/models/flows/input/FileInput.java#L28-L53","documentation":"Thrown by FileInput.validate() when the uploaded file's extension is not in the configured allowedFileExtensions list. The validator extracts the extension from the URI path (lowercased, including the dot) and checks membership. If allowedFileExtensions is null or empty the check is skipped (all types allowed); otherwise an exact match is required. This is a ConstraintViolationException surfaced via Bean Validation.","triggerScenarios":"A flow defines FileInput with allowedFileExtensions: ['.csv','.txt'] and the execution uploads a .xlsx; the uploaded URI has no extension (returns empty string, not in the list); the extension case differs but lowercasing still misses because the list entry lacks the dot.","commonSituations":"allowedFileExtensions entries written without a leading dot (e.g., 'csv' instead of '.csv'); users uploading exported files in a different format; the .upl default extension used by Kestra's internal upload path is excluded.","solutions":["Ensure every entry in allowedFileExtensions starts with a dot (e.g., '.csv').","Convert or re-export the uploaded file to one of the allowed types.","If multiple types are acceptable, add all of them to the list.","Verify the uploaded URI retains the real extension and is not stripped to '.upl'."],"exampleFix":"# before\ninputs:\n  - id: data\n    type: FILE\n    allowedFileExtensions: [csv, txt]   # missing dots\n\n# after\ninputs:\n  - id: data\n    type: FILE\n    allowedFileExtensions: [.csv, .txt]","handlingStrategy":"validation","validationCode":"String ext = getFileExtension(uri);\nif (allowedFileExtensions != null && !allowedFileExtensions.isEmpty()\n    && !allowedFileExtensions.contains(ext.toLowerCase())) {\n    throw new ConstraintViolationException(\n        \"File type not allowed. Accepted extensions: \" + String.join(\", \", allowedFileExtensions), Set.of());\n}","typeGuard":null,"tryCatchPattern":"try {\n    fileInput.validate(uploadedUri);\n} catch (ConstraintViolationException e) {\n    // prompt user to re-upload with an accepted extension\n    log.warn(\"Upload rejected: {}\", e.getMessage());\n}","preventionTips":["Always include the leading dot in allowedFileExtensions entries.","Surface the allowed list to the user at upload time."],"tags":["flow-input","validation","file-upload","file-extension"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}