kestra-io/kestra · error · ConstraintViolationException

File type not allowed. Accepted extensions: <allowedFileExte

Error message

File type not allowed. Accepted extensions: <allowedFileExtensions>

What it means

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.

Source

Thrown at core/src/main/java/io/kestra/core/models/flows/input/FileInput.java:46

    /**
     * Gets the file extension from the URI's path
     */
    private String getFileExtension(URI uri) {
        String path = uri.getPath();
        int lastDotIndex = path.lastIndexOf(".");
        return lastDotIndex >= 0 ? path.substring(lastDotIndex).toLowerCase() : "";
    }

    @Override
    public void validate(URI input) throws ConstraintViolationException {
        if (input == null || allowedFileExtensions == null || allowedFileExtensions.isEmpty()) {
            return;
        }

        String extension = getFileExtension(input);
        if (!allowedFileExtensions.contains(extension.toLowerCase())) {
            throw new ConstraintViolationException(
                "File type not allowed. Accepted extensions: " + String.join(", ", allowedFileExtensions),
                Set.of()
            );
        }
    }
}

View on GitHub (pinned to 823fada927)

Solutions

  1. Ensure every entry in allowedFileExtensions starts with a dot (e.g., '.csv').
  2. Convert or re-export the uploaded file to one of the allowed types.
  3. If multiple types are acceptable, add all of them to the list.
  4. Verify the uploaded URI retains the real extension and is not stripped to '.upl'.

Example fix

# before
inputs:
  - id: data
    type: FILE
    allowedFileExtensions: [csv, txt]   # missing dots

# after
inputs:
  - id: data
    type: FILE
    allowedFileExtensions: [.csv, .txt]
Defensive patterns

Strategy: validation

Validate before calling

String ext = getFileExtension(uri);
if (allowedFileExtensions != null && !allowedFileExtensions.isEmpty()
    && !allowedFileExtensions.contains(ext.toLowerCase())) {
    throw new ConstraintViolationException(
        "File type not allowed. Accepted extensions: " + String.join(", ", allowedFileExtensions), Set.of());
}

Try / catch

try {
    fileInput.validate(uploadedUri);
} catch (ConstraintViolationException e) {
    // prompt user to re-upload with an accepted extension
    log.warn("Upload rejected: {}", e.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14). Data as JSON: /api/errors/0f6c41390bf7c029. Report an issue: GitHub.