apache/dolphinscheduler · error · ServiceException

The resource is already exist: ${resourceAbsolutePath}

Error message

The resource is already exist: ${resourceAbsolutePath}

What it means

exceptionResourceExists throws this ServiceException when creating or renaming a resource but the target absolute path already exists in storage. It prevents silently overwriting existing files/directories.

Source

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

        }
    }

    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);
        }
    }

    public void exceptionResourceIsNotFile(String fileAbsolutePath) {
        if (StringUtils.isEmpty(Files.getFileExtension(fileAbsolutePath))) {
            throw new ServiceException("The path is not a file: " + fileAbsolutePath);
        }
    }

    public void exceptionUserNoResourcePermission(User user, AbstractResourceDto resourceDto) {
        exceptionUserNoResourcePermission(user, resourceDto.getResourceAbsolutePath());
    }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Choose a different file/directory name or delete the existing resource first.
  2. Use an update/overwrite API instead of create when replacement is intended.
  3. Check existence with storageOperator.exists(targetPath) before calling create.
  4. Version filenames (e.g. append timestamp) for idempotent uploads.

Example fix

// before
resourceService.createResource(loginUser, path, "SH", content);
// after
if (!storageOperator.exists(path)) {
    resourceService.createResource(loginUser, path, "SH", content);
} else {
    resourceService.updateResource(loginUser, path, content); // or pick a new name
}
Defensive patterns

Strategy: validation

Validate before calling

if (storageOperator.exists(targetPath)) { throw new IllegalStateException("Target already exists: " + targetPath); }

Try / catch

try { createResource(...); } catch (ServiceException e) { if (e.getMessage().contains("already exist")) { /* prompt for a new name or switch to update */ } else { throw e; } }

Prevention

When it happens

Trigger: POST/PUT resource creation where the requested name collides with an existing file/directory at the same absolute path (e.g. re-creating 'dir/script.sh' that already exists), or a rename/move targeting an occupied path.

Common situations: Re-running a deployment script that uploads resources without unique names; two users independently creating a same-named file; retrying a create after a partial success that already wrote the file.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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