apolloconfig/apollo · error · BadRequestException
Can't rollback namespace
Error message
Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release
What it means
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.
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.
Example fix
// before: only one active release exists releaseService.rollback(releaseId, operator); // 400 // after: publish the desired state as a new release releaseService.publish(appId, env, clusterName, namespaceName, name, comment, operator, false, null);
Defensive patterns
Strategy: validation
Validate before calling
PageRequest page = PageRequest.of(0, 2);
List<Release> active = releaseService.findActiveReleases(appId, clusterName, namespaceName, page);
if (active == null || active.size() < 2) {
// publish a new release instead of rolling back
} Try / catch
try {
releaseService.rollback(releaseId, operator);
} catch (BadRequestException e) {
if (e.getMessage().contains("only one active release")) {
// fall back to publishing a new release
} else throw e;
} Prevention
- Disable the rollback UI action when active-release count < 2.
- Prefer publishing a corrective release for first-publish namespaces.
When it happens
Trigger: Calling rollback on a namespace that has only ever had one active release (the initial/first publish), or whose prior releases were all abandoned.
Common situations: Attempting to roll back the very first publish; namespaces where earlier releases were already abandoned leaving no fallback.
Related errors
- current release equal to target release
- release is not active
- Config can not be published by yourself.
- Env: is not supported emergency publish now
- key too long. length limit
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/e34b5d834b1123b6.
Report an issue: GitHub.
Appendix: source
Thrown at apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java:469
@Transactional
public Release rollback(long releaseId, String operator) {
Release release = findOne(releaseId);
if (release == null) {
throw NotFoundException.releaseNotFound(releaseId);
}
if (release.isAbandoned()) {
throw new BadRequestException("release is not active");
}
String appId = release.getAppId();
String clusterName = release.getClusterName();
String namespaceName = release.getNamespaceName();
PageRequest page = PageRequest.of(0, 2);
List<Release> twoLatestActiveReleases =
findActiveReleases(appId, clusterName, namespaceName, page);
if (twoLatestActiveReleases == null || twoLatestActiveReleases.size() < 2) {
throw new BadRequestException(
"Can't rollback namespace(appId=%s, clusterName=%s, namespaceName=%s) because there is only one active release",
appId, clusterName, namespaceName);
}
release.setAbandoned(true);
release.setDataChangeLastModifiedBy(operator);
releaseRepository.save(release);
releaseHistoryService.createReleaseHistory(appId, clusterName, namespaceName, clusterName,
twoLatestActiveReleases.get(1).getId(), release.getId(), ReleaseOperation.ROLLBACK, null,
operator);
// publish child namespace if namespace has child
rollbackChildNamespace(appId, clusterName, namespaceName, twoLatestActiveReleases, operator);
return release;
}View on GitHub (pinned to d95fc18d11)