{"record":{"id":"7ab979fbc0bd1cc6","repo":"apolloconfig/apollo","slug":"namespace-s-branch-not-exist-appid-s-clustern","errorCode":null,"errorMessage":"Namespace's branch not exist. AppId = %s, ClusterName = %s, NamespaceName = %s, BranchName = %s","messagePattern":"Namespace's branch not exist\\. AppId = (.+?), ClusterName = (.+?), NamespaceName = (.+?), BranchName = (.+?)","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceBranchController.java","lineNumber":152,"sourceCode":"    checkNamespace(appId, clusterName, namespaceName);\n\n    Namespace childNamespace = namespaceBranchService.findBranch(appId, clusterName, namespaceName);\n    if (childNamespace == null) {\n      return null;\n    }\n\n    return BeanUtils.transform(NamespaceDTO.class, childNamespace);\n  }\n\n  private void checkBranch(String appId, String clusterName, String namespaceName,\n      String branchName) {\n    // 1. check parent namespace\n    checkNamespace(appId, clusterName, namespaceName);\n\n    // 2. check child namespace\n    Namespace childNamespace = namespaceService.findOne(appId, branchName, namespaceName);\n    if (childNamespace == null) {\n      throw new BadRequestException(\n          \"Namespace's branch not exist. AppId = %s, ClusterName = %s, NamespaceName = %s, BranchName = %s\",\n          appId, clusterName, namespaceName, branchName);\n    }\n\n  }\n\n  private void checkNamespace(String appId, String clusterName, String namespaceName) {\n    Namespace parentNamespace = namespaceService.findOne(appId, clusterName, namespaceName);\n    if (parentNamespace == null) {\n      throw BadRequestException.namespaceNotExists(appId, clusterName, namespaceName);\n    }\n  }\n\n\n}\n","sourceCodeStart":134,"sourceCodeEnd":168,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceBranchController.java#L134-L168","documentation":"A BadRequestException (HTTP 400) thrown from NamespaceBranchController.checkBranch() when a gray-release branch (child namespace) is not found. The check first validates the parent namespace exists, then looks up the child namespace by appId + branchName + namespaceName via namespaceService.findOne(). A null result means the specified branch does not exist for the given parent. The message includes all four identifiers for diagnostics.","triggerScenarios":"Any namespace-branch operation (update branch rules, merge, delete branch) that calls checkBranch() with a branchName that does not resolve to a child Namespace for the given appId/clusterName/namespaceName. For example, calling the branch-update endpoint with a stale or incorrect branchName.","commonSituations":"The branch was already deleted by another operator; the branchName was mistyped or copy-pasted incorrectly; the branch was never created (the gray release was initiated but the branch namespace was not persisted); cross-environment confusion where a branch name from one env is used in another.","solutions":["Verify the branchName exists by listing branches for the parent namespace before operating on it.","Check that the branch was not deleted by another user or process.","Ensure appId, clusterName, namespaceName, and branchName are all correct and correspond to the intended environment.","If the branch should exist, create it via the branch-creation endpoint first."],"exampleFix":"// before: assume branch exists\nbranchApi.updateBranchRules(appId, env, clusterName, namespaceName, branchName, rules);\n\n// after: verify branch existence first\nList<NamespaceDTO> branches = branchApi.findBranches(appId, env, clusterName, namespaceName);\nboolean exists = branches.stream().anyMatch(b -> branchName.equals(b.getClusterName()));\nif (!exists) {\n    throw new IllegalStateException(\"Branch does not exist, create it first\");\n}\nbranchApi.updateBranchRules(appId, env, clusterName, namespaceName, branchName, rules);","handlingStrategy":"validation","validationCode":"// Verify the branch exists before operating\nList<NamespaceDTO> branches = branchApi.findBranches(appId, env, clusterName, namespaceName);\nboolean branchExists = branches.stream()\n    .anyMatch(b -> branchName.equals(b.getClusterName()));\nif (!branchExists) {\n    // create branch or abort\n    throw new IllegalStateException(\"Branch not found: \" + branchName);\n}\nbranchApi.updateBranchRules(appId, env, clusterName, namespaceName, branchName, rules);","typeGuard":null,"tryCatchPattern":"try {\n    branchApi.updateBranchRules(appId, env, clusterName, namespaceName, branchName, rules);\n} catch (BadRequestException e) {\n    if (e.getMessage().contains(\"branch not exist\")) {\n        // Branch was deleted or never existed; recreate or abort\n        handleMissingBranch(appId, clusterName, namespaceName, branchName);\n    } else {\n        throw e;\n    }\n}","preventionTips":["List branches for the parent namespace before performing branch operations.","Cache branch existence checks with a short TTL to reduce redundant lookups.","Handle branch-deleted scenarios gracefully in the UI and API clients."],"tags":["namespace","branch","gray-release","not-found","bad-request","apollo-adminservice"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}