apache/dolphinscheduler · warning · ServiceException
The file type: ${fileExtension} cannot be fetched
Error message
The file type: ${fileExtension} cannot be fetched What it means
exceptionFileContentCannotFetch checks the extension of the requested file against FILE_SUFFIXES_WHICH_CAN_FETCH_CONTENT (a whitelist of text-like suffixes such as .sql, .sh, .py, .txt). If the extension is not in the whitelist, viewing the file's content via the API is refused with ServiceException("The file type: {ext} cannot be fetched"), because binary files cannot be rendered as text.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java:83
}
}
public void exceptionFileInvalidated(MultipartFile file) {
if (file == null) {
throw new ServiceException("The file is null");
}
}
public void exceptionFileContentInvalidated(String fileContent) {
if (StringUtils.isEmpty(fileContent)) {
throw new ServiceException("The file content is null");
}
}
public void exceptionFileContentCannotFetch(String fileAbsolutePath) {
String fileExtension = Files.getFileExtension(fileAbsolutePath);
if (!FILE_SUFFIXES_WHICH_CAN_FETCH_CONTENT.contains(fileExtension)) {
throw new ServiceException("The file type: " + fileExtension + " cannot be fetched");
}
}
public void exceptionResourceNotExists(String resourceAbsolutePath) {
if (!storageOperator.exists(resourceAbsolutePath)) {
throw new ServiceException("Thr resource is not exists: " + resourceAbsolutePath);
}
}
public void exceptionResourceExists(String resourceAbsolutePath) {
if (storageOperator.exists(resourceAbsolutePath)) {
throw new ServiceException("The resource is already exist: " + resourceAbsolutePath);
}
}
public void exceptionResourceIsNotDirectory(String resourceAbsolutePath) {
if (StringUtils.isNotEmpty(Files.getFileExtension(resourceAbsolutePath))) {
throw new ServiceException("The path is not a directory: " + resourceAbsolutePath);View on GitHub (pinned to 02eac45a1b)
Solutions
- Download the file instead of fetching inline content for binary types (jar, zip, images, etc.).
- Rename/convert the file to a whitelisted text extension if it truly is text (and re-upload if needed).
- If a new text type is legitimately needed, add its extension to FILE_SUFFIXES_WHICH_CAN_FETCH_CONTENT in the source and redeploy.
Example fix
// before GET /resources/view?path=/alice/resources/app.jar // binary // after GET /resources/download?path=/alice/resources/app.jar // or view a .sql/.sh/.py file instead
Defensive patterns
Strategy: validation
Validate before calling
// client-side pre-check against the server whitelist
const viewable = ['.sh', '.bat', '.sql', '.py', '.txt', '.md', '.properties', '.yml', '.yaml', '.json', '.xml'];
if (!viewable.includes(extension.toLowerCase())) {
// use the download endpoint instead of view-content
} Type guard
function isViewableTextFile(fileName) {
const ext = fileName.slice(fileName.lastIndexOf('.') + 1).toLowerCase();
return ['.sql', '.sh', '.py', '.txt', '.md', '.yml', '.yaml', '.json', '.xml', '.properties'].includes('.' + ext);
} Try / catch
try {
// view resource content
} catch (ServiceException e) {
if (e.getMessage().startsWith("The file type:")) {
// fall back to the download endpoint for this file
} else throw e;
} Prevention
- Show the 'view content' action only for whitelisted text extensions in the UI
- Keep file extensions consistent (lowercase, standard) when uploading
- Use download for binary files (jar, zip, images) instead of content fetch
When it happens
Trigger: Calling the 'view resource content' endpoint for a binary file (e.g. .jar, .zip, .xlsx, .tar.gz) or a file with an unusual/missing extension.
Common situations: User clicks 'view' in the resource center on an uploaded jar/zip; extension uppercase or non-standard (e.g. .SQL vs .sql) not matching the whitelist; uploading files whose extension was changed after creation.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Can not find valid resource by name %s
- Unsupported executeType: {0}
- 20016
- ILLEGAL_RESOURCE_PATH
- The resource path is null
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/85b7f70a35f84e49.
Report an issue: GitHub.