{"record":{"id":"f18e3fdb7a1dfd7a","repo":"apache/dolphinscheduler","slug":"the-resource-is-already-exist-resourceabsolutep","errorCode":null,"errorMessage":"The resource is already exist: ${resourceAbsolutePath}","messagePattern":"The resource is already exist: (.+?)","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java","lineNumber":95,"sourceCode":"        }\n    }\n\n    public void exceptionFileContentCannotFetch(String fileAbsolutePath) {\n        String fileExtension = Files.getFileExtension(fileAbsolutePath);\n        if (!FILE_SUFFIXES_WHICH_CAN_FETCH_CONTENT.contains(fileExtension)) {\n            throw new ServiceException(\"The file type: \" + fileExtension + \" cannot be fetched\");\n        }\n    }\n\n    public void exceptionResourceNotExists(String resourceAbsolutePath) {\n        if (!storageOperator.exists(resourceAbsolutePath)) {\n            throw new ServiceException(\"Thr resource is not exists: \" + resourceAbsolutePath);\n        }\n    }\n\n    public void exceptionResourceExists(String resourceAbsolutePath) {\n        if (storageOperator.exists(resourceAbsolutePath)) {\n            throw new ServiceException(\"The resource is already exist: \" + resourceAbsolutePath);\n        }\n    }\n\n    public void exceptionResourceIsNotDirectory(String resourceAbsolutePath) {\n        if (StringUtils.isNotEmpty(Files.getFileExtension(resourceAbsolutePath))) {\n            throw new ServiceException(\"The path is not a directory: \" + resourceAbsolutePath);\n        }\n    }\n\n    public void exceptionResourceIsNotFile(String fileAbsolutePath) {\n        if (StringUtils.isEmpty(Files.getFileExtension(fileAbsolutePath))) {\n            throw new ServiceException(\"The path is not a file: \" + fileAbsolutePath);\n        }\n    }\n\n    public void exceptionUserNoResourcePermission(User user, AbstractResourceDto resourceDto) {\n        exceptionUserNoResourcePermission(user, resourceDto.getResourceAbsolutePath());\n    }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java#L77-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Choose a different file/directory name or delete the existing resource first.","Use an update/overwrite API instead of create when replacement is intended.","Check existence with storageOperator.exists(targetPath) before calling create.","Version filenames (e.g. append timestamp) for idempotent uploads."],"exampleFix":"// before\nresourceService.createResource(loginUser, path, \"SH\", content);\n// after\nif (!storageOperator.exists(path)) {\n    resourceService.createResource(loginUser, path, \"SH\", content);\n} else {\n    resourceService.updateResource(loginUser, path, content); // or pick a new name\n}","handlingStrategy":"validation","validationCode":"if (storageOperator.exists(targetPath)) { throw new IllegalStateException(\"Target already exists: \" + targetPath); }","typeGuard":null,"tryCatchPattern":"try { createResource(...); } catch (ServiceException e) { if (e.getMessage().contains(\"already exist\")) { /* prompt for a new name or switch to update */ } else { throw e; } }","preventionTips":["Generate unique names (timestamp/UUID suffix) for automated uploads.","Make create operations idempotent: check existence then update if present.","Avoid retrying failed creates without checking whether the first attempt partially succeeded."],"tags":["resource","conflict","already-exists","dolphinscheduler"],"backgroundTag":"file-already-exists","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}