{"record":{"id":"d801912c3ae99c99","repo":"apache/dolphinscheduler","slug":"120033","errorCode":"120033","errorMessage":"this cluster can not found in db.","messagePattern":"this cluster can not found in db\\.","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java","lineNumber":240,"sourceCode":"                                       String desc) {\n        if (isNotAdmin(loginUser)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        if (checkDescriptionLength(desc)) {\n            throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);\n        }\n\n        checkParams(name, config);\n\n        Cluster clusterExistByName = clusterDao.queryByClusterName(name);\n        if (clusterExistByName != null && !clusterExistByName.getCode().equals(code)) {\n            throw new ServiceException(Status.CLUSTER_NAME_EXISTS, name);\n        }\n\n        Cluster clusterExist = clusterDao.queryByClusterCode(code);\n        if (clusterExist == null) {\n            throw new ServiceException(Status.CLUSTER_NOT_EXISTS, name);\n        }\n\n        if (!Constants.K8S_LOCAL_TEST_CLUSTER_CODE.equals(clusterExist.getCode())\n                && !config.equals(ClusterConfUtils.getK8sConfig(clusterExist.getConfig()))) {\n            try {\n                k8sManager.getAndUpdateK8sClient(code, true);\n            } catch (Exception e) {\n                throw new ServiceException(Status.K8S_CLIENT_OPS_ERROR, name);\n            }\n        }\n\n        // update cluster\n        // need not update relation\n        clusterExist.setConfig(config);\n        clusterExist.setName(name);\n        clusterExist.setDescription(desc);\n        clusterExist.setUpdateTime(DateUtils.getCurrentDate());\n        clusterDao.updateById(clusterExist);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java#L222-L258","documentation":"updateClusterByCode looks up the target cluster by code via clusterDao.queryByClusterCode(code); when no row is found it throws ServiceException(Status.CLUSTER_NOT_EXISTS, name; code 120033). You cannot update a cluster registration that does not exist in the database.","triggerScenarios":"PUT /clusters/{code} (or updateClusterByCode) with a cluster code that has no row in t_ds_cluster — wrong code, cluster already deleted, or code from another environment's database.","commonSituations":"Stale UI tab after another admin deleted the cluster; scripts referencing hard-coded codes copied from a different installation; updates after a failed migration left clusters missing.","solutions":["Verify the cluster code via the cluster list API/clusterDao.queryByClusterCode before updating.","Recreate the cluster if it was deleted unintentionally (POST cluster endpoint).","Correct the code in the calling script/UI; codes are generated per environment and are not portable.","If the cluster exists but query fails, check DB connectivity and that the API points to the right database."],"exampleFix":"// before\nclusterService.updateClusterByCode(loginUser, 12345L, name, config, desc);\n// after\nCluster c = clusterDao.queryByClusterCode(12345L);\nif (c == null) {\n    throw new IllegalArgumentException(\"cluster 12345 not found; create it first\");\n}\nclusterService.updateClusterByCode(loginUser, 12345L, name, config, desc);","handlingStrategy":"validation","validationCode":"// Java\nCluster cluster = clusterDao.queryByClusterCode(code);\nif (cluster == null) {\n    throw new IllegalArgumentException(\"cluster \" + code + \" does not exist; create it before updating\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    clusterService.updateClusterByCode(loginUser, code, name, config, desc);\n} catch (ServiceException e) {\n    if (e.getCode() == 120033) {\n        // refresh cluster list; code may be stale or cluster deleted\n    } else {\n        throw e;\n    }\n}","preventionTips":["Never hard-code cluster codes in scripts; resolve by name first","Re-fetch cluster lists after concurrent admin operations","Create the cluster before attempting updates"],"tags":["cluster","not-found","database"],"backgroundTag":"entity-not-found","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"}