{"record":{"id":"e34b5d834b1123b6","repo":"apolloconfig/apollo","slug":"can-t-rollback-namespace-appid-s-clustername-s","errorCode":null,"errorMessage":"Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release","messagePattern":"Can't rollback namespace\\(appId=(.+?), clusterName=(.+?), namespaceName=(.+?)\\) because there is only one active release","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java","lineNumber":469,"sourceCode":"  @Transactional\n  public Release rollback(long releaseId, String operator) {\n    Release release = findOne(releaseId);\n    if (release == null) {\n      throw NotFoundException.releaseNotFound(releaseId);\n    }\n    if (release.isAbandoned()) {\n      throw new BadRequestException(\"release is not active\");\n    }\n\n    String appId = release.getAppId();\n    String clusterName = release.getClusterName();\n    String namespaceName = release.getNamespaceName();\n\n    PageRequest page = PageRequest.of(0, 2);\n    List<Release> twoLatestActiveReleases =\n        findActiveReleases(appId, clusterName, namespaceName, page);\n    if (twoLatestActiveReleases == null || twoLatestActiveReleases.size() < 2) {\n      throw new BadRequestException(\n          \"Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release\",\n          appId, clusterName, namespaceName);\n    }\n\n    release.setAbandoned(true);\n    release.setDataChangeLastModifiedBy(operator);\n\n    releaseRepository.save(release);\n\n    releaseHistoryService.createReleaseHistory(appId, clusterName, namespaceName, clusterName,\n        twoLatestActiveReleases.get(1).getId(), release.getId(), ReleaseOperation.ROLLBACK, null,\n        operator);\n\n    // publish child namespace if namespace has child\n    rollbackChildNamespace(appId, clusterName, namespaceName, twoLatestActiveReleases, operator);\n\n    return release;\n  }","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java#L451-L487","documentation":"Thrown as BadRequestException (HTTP 400) by ReleaseService.rollback when there are fewer than two active releases for the (appId, clusterName, namespaceName). Rollback works by abandoning the current release so the previous one becomes active — that requires at least one prior active release to fall back to.","triggerScenarios":"Calling rollback on a namespace that has only ever had one active release (the initial/first publish), or whose prior releases were all abandoned.","commonSituations":"Attempting to roll back the very first publish; namespaces where earlier releases were already abandoned leaving no fallback.","solutions":["Do not use rollback here — instead publish a new release containing the desired configuration.","Verify release history has >= 2 active releases before offering a rollback action in the UI/client."],"exampleFix":"// before: only one active release exists\nreleaseService.rollback(releaseId, operator); // 400\n// after: publish the desired state as a new release\nreleaseService.publish(appId, env, clusterName, namespaceName, name, comment, operator, false, null);","handlingStrategy":"validation","validationCode":"PageRequest page = PageRequest.of(0, 2);\nList<Release> active = releaseService.findActiveReleases(appId, clusterName, namespaceName, page);\nif (active == null || active.size() < 2) {\n  // publish a new release instead of rolling back\n}","typeGuard":null,"tryCatchPattern":"try {\n  releaseService.rollback(releaseId, operator);\n} catch (BadRequestException e) {\n  if (e.getMessage().contains(\"only one active release\")) {\n    // fall back to publishing a new release\n  } else throw e;\n}","preventionTips":["Disable the rollback UI action when active-release count < 2.","Prefer publishing a corrective release for first-publish namespaces."],"tags":["release","rollback","bad-request","apollo-biz","validation"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}