{"record":{"id":"30fd567611894558","repo":"apache/dolphinscheduler","slug":"file-dstpath-already-exists-30fd56","errorCode":null,"errorMessage":"file: ${dstPath} already exists","messagePattern":"file: (.+?) already exists","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-storage-plugin/dolphinscheduler-storage-oss/src/main/java/org/apache/dolphinscheduler/plugin/storage/oss/OssStorageOperator.java","lineNumber":196,"sourceCode":"\n    @Override\n    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {\n        srcPath = transformAbsolutePathToOssKey(srcPath);\n        dstPath = transformAbsolutePathToOssKey(dstPath);\n\n        ossClient.copyObject(bucketName, srcPath, bucketName, dstPath);\n        if (deleteSource) {\n            ossClient.deleteObject(bucketName, srcPath);\n        }\n    }\n\n    @SneakyThrows\n    @Override\n    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {\n        dstPath = transformAbsolutePathToOssKey(dstPath);\n        if (ossClient.doesObjectExist(bucketName, dstPath)) {\n            if (!overwrite) {\n                throw new FileAlreadyExistsException(\"file: \" + dstPath + \" already exists\");\n            } else {\n                ossClient.deleteObject(bucketName, dstPath);\n            }\n\n        }\n        ossClient.putObject(bucketName, dstPath, new File(srcFile));\n        if (deleteSource) {\n            Files.delete(Paths.get(srcFile));\n        }\n    }\n\n    @SneakyThrows\n    @Override\n    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {\n        filePath = transformAbsolutePathToOssKey(filePath);\n        OSSObject ossObject = ossClient.getObject(bucketName, filePath);\n        try (\n                InputStreamReader inputStreamReader = new InputStreamReader(ossObject.getObjectContent());","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-storage-plugin/dolphinscheduler-storage-oss/src/main/java/org/apache/dolphinscheduler/plugin/storage/oss/OssStorageOperator.java#L178-L214","documentation":"OssStorageOperator.upload throws FileAlreadyExistsException when the destination OSS key exists and overwrite=false. Unlike the OBS operator which throws ObsException, this one throws the JDK FileAlreadyExistsException.","triggerScenarios":"Calling upload(srcFile, dstPath, deleteSource, false) where ossClient.doesObjectExist reports the dstPath key already exists.","commonSituations":"Repeated uploads to a fixed resource path without overwrite; leftover object from a failed prior run; two tasks uploading to the same destination concurrently.","solutions":["Pass overwrite=true to replace the existing object","Delete the destination object before uploading","Use a unique dstPath per run"],"exampleFix":"// before\nstorageOperator.upload(src, dst, false, false);\n// after\nif (storageOperator.existsStorageFile(dst)) {\n    storageOperator.upload(src, dst, false, true);\n} else {\n    storageOperator.upload(src, dst, false, false);\n}","handlingStrategy":"validation","validationCode":"if (storageOperator.existsStorageFile(dstPath) && !overwrite) {\n    throw new IllegalStateException(\"Refusing to upload to existing path \" + dstPath);\n}\nstorageOperator.upload(srcFile, dstPath, deleteSource, overwrite);","typeGuard":null,"tryCatchPattern":"try {\n    storageOperator.upload(src, dst, false, false);\n} catch (FileAlreadyExistsException e) {\n    log.warn(\"{} exists, retrying with overwrite\", dst);\n    storageOperator.upload(src, dst, false, true);\n}","preventionTips":["Set overwrite=true deliberately when re-uploading to fixed paths","Version destination keys instead of overwriting when history matters","Serialize uploads to the same destination across concurrent tasks"],"tags":["storage","oss","file-already-exists","overwrite"],"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"}