{"record":{"id":"0e0e0715452cf5f4","repo":"apache/dolphinscheduler","slug":"120022","errorCode":"120022","errorMessage":"this cluster name shouldn't be empty.","messagePattern":"this cluster name shouldn't be empty\\.","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java","lineNumber":276,"sourceCode":"        clusterDao.updateById(clusterExist);\n        return clusterExist;\n    }\n\n    /**\n     * verify cluster name\n     *\n     * @param loginUser   login user\n     * @param clusterName cluster name\n     * @return true if the cluster name not exists, otherwise return false\n     */\n    @Override\n    public void verifyCluster(User loginUser, String clusterName) {\n        if (isNotAdmin(loginUser)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        if (StringUtils.isEmpty(clusterName)) {\n            throw new ServiceException(Status.CLUSTER_NAME_IS_NULL);\n        }\n\n        Cluster cluster = clusterDao.queryByClusterName(clusterName);\n        if (cluster != null) {\n            throw new ServiceException(Status.CLUSTER_NAME_EXISTS);\n        }\n    }\n\n    protected void checkParams(String name, String config) {\n        if (StringUtils.isEmpty(name)) {\n            throw new ServiceException(Status.CLUSTER_NAME_IS_NULL);\n        }\n        if (StringUtils.isEmpty(config)) {\n            throw new ServiceException(Status.CLUSTER_CONFIG_IS_NULL);\n        }\n    }\n\n}","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java#L258-L294","documentation":"verifyCluster validates that the cluster name is non-empty; if StringUtils.isEmpty(clusterName) it throws ServiceException(Status.CLUSTER_NAME_IS_NULL, code 120022) with message \"this cluster name shouldn't be empty.\". It is the first input check before querying the database for name uniqueness.","triggerScenarios":"GET /clusters/verify (or verifyCluster) called with clusterName=\"\", null, or a whitespace-only name — usually a form submitted before the name field was filled or a missing query parameter.","commonSituations":"Frontend calling the verify API on field focus before any input; scripts interpolating an unset variable into the URL; clients trimming names to empty strings.","solutions":["Only call verifyCluster after the user entered a name; validate non-empty client-side.","Trim the input and check for emptiness before invoking the endpoint.","Fix scripts to fail fast when the name variable is unset.","Ensure the query parameter is properly included in the request."],"exampleFix":"// before\nString name = config.getProperty(\"cluster.name\");\nclusterService.verifyCluster(loginUser, name);\n// after\nString name = config.getProperty(\"cluster.name\");\nif (name == null || name.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"cluster name required\");\n}\nclusterService.verifyCluster(loginUser, name.trim());","handlingStrategy":"validation","validationCode":"// Java\nif (name == null || name.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"clusterName must be non-empty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call the verify endpoint with a populated, trimmed name","Add required-field validation in forms before firing verify requests","Fail fast in scripts when the name variable is unset"],"tags":["validation","empty-input","cluster"],"backgroundTag":"empty-required-field","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"}