apolloconfig/apollo · warning · BadRequestException

Env: %s is not supported emergency publish now

Error message

Env: %s is not supported emergency publish now

What it means

BadRequestException (HTTP 400) from NamespaceBranchController.merge (gray-branch merge). If the submitted NamespaceReleaseModel.isEmergencyPublish() is true but portalConfig.isEmergencyPublishAllowed(Env.valueOf(env)) returns false for that environment, the merge is rejected with the env name filled into %s.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java:141

        branchName, userInfoHolder.getUser().getUserId());

  }



  @PreAuthorize(
      value = "@unifiedPermissionValidator.hasModifyNamespacePermission(#appId, #env, #clusterName, #namespaceName)")
  @PostMapping(
      value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge")
  @ApolloAuditLog(type = OpType.UPDATE, name = "NamespaceBranch.merge")
  public ReleaseDTO merge(@PathVariable String appId, @PathVariable String env,
      @PathVariable String clusterName, @PathVariable String namespaceName,
      @PathVariable String branchName,
      @RequestParam(value = "deleteBranch", defaultValue = "true") boolean deleteBranch,
      @RequestBody NamespaceReleaseModel model) {

    if (model.isEmergencyPublish() && !portalConfig.isEmergencyPublishAllowed(Env.valueOf(env))) {
      throw new BadRequestException("Env: %s is not supported emergency publish now", env);
    }

    ReleaseDTO createdRelease = namespaceBranchService.merge(appId, Env.valueOf(env), clusterName,
        namespaceName, branchName, model.getReleaseTitle(), model.getReleaseComment(),
        model.isEmergencyPublish(), deleteBranch, userInfoHolder.getUser().getUserId());

    ConfigPublishEvent event = ConfigPublishEvent.instance();
    event.withAppId(appId).withCluster(clusterName).withNamespace(namespaceName)
        .withReleaseId(createdRelease.getId()).setMergeEvent(true).setEnv(Env.valueOf(env));

    publisher.publishEvent(event);

    return createdRelease;
  }


  @GetMapping(
      value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules")

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Do not set emergencyPublish=true for envs not in the allowlist; submit a normal merge for those.
  2. If the env should support it, add it to portal's emergency publish supportedEnvs config.
  3. Gate the flag by env in your automation (see validationCode).
  4. Confirm the env name spelling matches an allowlisted entry.

Example fix

// before
model.setEmergencyPublish(true);  // sent for PROD -> 400

// after
model.setEmergencyPublish(emergencyAllowedEnvs.contains(env));
Defensive patterns

Strategy: validation

Validate before calling

// Only request emergency publish for allowlisted envs; fall back to normal merge.
boolean emergency = model.isEmergencyPublish()
    && emergencyAllowedEnvs.contains(env.toUpperCase(Locale.ROOT));
model.setEmergencyPublish(emergency);
// if emergency==false here, the merge proceeds as a normal gray merge

Prevention

When it happens

Trigger: POST .../branches/{branchName}/merge with emergencyPublish=true for an env that is not on the portal's emergency-publish allowlist (portal config emergencyPublish.supportedEnvs).

Common situations: Prod is excluded from emergency publish by policy; config not updated after adding a new env; a script reusing emergencyPublish=true across all envs.

Related errors


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/c02abb1229067c5d. Report an issue: GitHub.