{"record":{"id":"89e3d8fb9d716c79","repo":"alibaba/nacos","slug":"does-not-exist","errorCode":null,"errorMessage":"{} does not exist","messagePattern":"(.+?) does not exist","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java","lineNumber":252,"sourceCode":"            if (fileOrDir.exists()) {\n                boolean isDeleteOk = fileOrDir.delete();\n                if (!isDeleteOk) {\n                    throw new IOException(\"delete fail\");\n                }\n            }\n        }\n    }\n    \n    /**\n     * 清理目录下的内容. Clean content under directory.\n     *\n     * @param directory directory\n     * @throws IOException io exception\n     */\n    public static void cleanDirectory(File directory) throws IOException {\n        if (!directory.exists()) {\n            String message = directory + \" does not exist\";\n            throw new IllegalArgumentException(message);\n        }\n        \n        if (!directory.isDirectory()) {\n            String message = directory + \" is not a directory\";\n            throw new IllegalArgumentException(message);\n        }\n        \n        File[] files = directory.listFiles();\n        // null if security restricted\n        if (files == null) {\n            throw new IOException(\"Failed to list contents of \" + directory);\n        }\n        \n        IOException exception = null;\n        for (File file : files) {\n            try {\n                delete(file);\n            } catch (IOException ioe) {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/utils/IoUtils.java#L234-L270","documentation":"Thrown by IoUtils.cleanDirectory(File) when directory.exists() is false. cleanDirectory requires an existing directory; a missing path is treated as an illegal argument (IllegalArgumentException, not IOException). The message includes the path.","triggerScenarios":"Calling cleanDirectory on a path that has not been created yet, or that was already deleted/concurrently removed before the call.","commonSituations":"Startup ordering where the directory is cleaned before it is created; a previous delete removed it; a config path that was never initialized; race with another cleaner.","solutions":["Guard with directory.exists() / directory.isDirectory() before calling cleanDirectory.","Create the directory first (mkdirs) if it may not exist, then clean.","If the directory being absent is acceptable, skip cleaning rather than treating it as an error."],"exampleFix":"// before\nIoUtils.cleanDirectory(dir);\n\n// after\nif (dir.exists() && dir.isDirectory()) {\n    IoUtils.cleanDirectory(dir);\n}","handlingStrategy":"validation","validationCode":"if (directory != null && directory.exists() && directory.isDirectory()) {\n    IoUtils.cleanDirectory(directory);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check exists() and isDirectory() before cleanDirectory.","Create the directory (mkdirs) first if it may not exist yet.","Treat a missing directory as a no-op when appropriate."],"tags":["io","filesystem","validation","directory","precondition"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}