{"record":{"id":"458e939f24823f27","repo":"apache/dolphinscheduler","slug":"file-dstpath-already-exists-458e93","errorCode":null,"errorMessage":"file: ${dstPath} already exists","messagePattern":"file: (.+?) already exists","errorType":"exception","errorClass":"ObsException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-storage-plugin/dolphinscheduler-storage-obs/src/main/java/org/apache/dolphinscheduler/plugin/storage/obs/ObsStorageOperator.java","lineNumber":156,"sourceCode":"    }\n\n    @Override\n    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {\n        srcPath = transformAbsolutePathToObsKey(srcPath);\n        dstPath = transformAbsolutePathToObsKey(dstPath);\n        obsClient.copyObject(bucketName, srcPath, bucketName, dstPath);\n        if (deleteSource) {\n            obsClient.deleteObject(bucketName, srcPath);\n        }\n    }\n\n    @SneakyThrows\n    @Override\n    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {\n        dstPath = transformAbsolutePathToObsKey(dstPath);\n        if (obsClient.doesObjectExist(bucketName, dstPath)) {\n            if (!overwrite) {\n                throw new ObsException(\"file: \" + dstPath + \" already exists\");\n            } else {\n                obsClient.deleteObject(bucketName, dstPath);\n            }\n        }\n        obsClient.putObject(bucketName, dstPath, new File(srcFile));\n        if (deleteSource) {\n            Files.delete(Paths.get(srcFile));\n        }\n\n    }\n\n    @SneakyThrows\n    @Override\n    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {\n        filePath = transformAbsolutePathToObsKey(filePath);\n        ObsObject obsObject = obsClient.getObject(bucketName, filePath);\n        try (\n                InputStreamReader inputStreamReader = new InputStreamReader(obsObject.getObjectContent());","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-storage-plugin/dolphinscheduler-storage-obs/src/main/java/org/apache/dolphinscheduler/plugin/storage/obs/ObsStorageOperator.java#L138-L174","documentation":"ObsStorageOperator.upload throws com.obs.services.ObsException when the destination key already exists in the bucket and overwrite=false. The operator explicitly checks doesObjectExist before uploading and aborts unless overwrite is true.","triggerScenarios":"Calling upload(srcFile, dstPath, deleteSource, false) where an object already exists at transformAbsolutePathToObsKey(dstPath).","commonSituations":"Re-uploading a resource file without setting overwrite=true; a previous partially-completed upload left the object; re-running a task that uploads to a fixed destination path.","solutions":["Pass overwrite=true to upload if replacing the object is intended","Delete the existing object first, then upload","Choose a different dstPath (versioned/timestamped key)"],"exampleFix":"// before\nstorageOperator.upload(src, dst, false, false);\n// after\nstorageOperator.upload(src, dst, false, true); // overwrite existing object","handlingStrategy":"validation","validationCode":"boolean exists = storageOperator.existsStorageFile(dstPath);\nstorageOperator.upload(srcFile, dstPath, deleteSource, exists ? true : overwrite);","typeGuard":null,"tryCatchPattern":"try {\n    storageOperator.upload(src, dst, false, overwrite);\n} catch (ObsException e) {\n    if (e.getMessage().contains(\"already exists\")) {\n        storageOperator.upload(src, dst, false, true);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Decide overwrite semantics explicitly at every upload call site","Prefer unique destination keys per execution over fixed paths","Clean up leftover objects from failed runs before re-uploading"],"tags":["storage","obs","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-14T00:17:10.932Z"}