apache/dolphinscheduler · error · ServiceException

The file content is null

Error message

The file content is null

What it means

exceptionFileContentInvalidated rejects an empty or null file content string with ServiceException("The file content is null"). Used by endpoints that create or update text resources (e.g. online file editor save) where the request body must include the content to write.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java:76

            throw new ServiceException("The resource path is null");
        }
        if (!resourceAbsolutePath.startsWith(storageOperator.getStorageBaseDirectory())) {
            throw new ServiceException("Invalidated resource path: " + resourceAbsolutePath);
        }
        if (resourceAbsolutePath.contains("..")) {
            throw new ServiceException("Invalidated resource path: " + resourceAbsolutePath);
        }
    }

    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)) {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Include a non-empty 'content' field in the request body when saving a text resource.
  2. If saving an intentionally empty file, first check the endpoint's expectations or use the file-upload path with a placeholder byte.
  3. Guard in client code: reject empty content before calling the save API.

Example fix

// before
{"resource_name":"script.sql", "content":""}
// after
{"resource_name":"script.sql", "content":"SELECT 1;"}
Defensive patterns

Strategy: validation

Validate before calling

// client-side pre-check
if (content == null || content.isEmpty()) {
    throw new IllegalArgumentException("content must be a non-empty string when saving a text resource");
}

Type guard

function hasContent(p) {
  return typeof p.content === 'string' && p.content.length > 0;
}

Try / catch

try {
    // save text resource
} catch (ServiceException e) {
    if (e.getMessage().contains("The file content is null")) {
        // prompt the user for content or abort the save
    } else throw e;
}

Prevention

When it happens

Trigger: Saving/creating a text resource (createOrUpdate online content API) with content=null or an empty string in the request payload.

Common situations: Frontend editor sends empty body when the buffer was never loaded; API scripts forget the content field; a failed read upstream produced an empty string passed through.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/b1371c611aca75b8. Report an issue: GitHub.