{"record":{"id":"c02abb1229067c5d","repo":"apolloconfig/apollo","slug":"env-s-is-not-supported-emergency-publish-now-c02abb","errorCode":null,"errorMessage":"Env: %s is not supported emergency publish now","messagePattern":"Env: (.+?) is not supported emergency publish now","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java","lineNumber":141,"sourceCode":"        branchName, userInfoHolder.getUser().getUserId());\n\n  }\n\n\n\n  @PreAuthorize(\n      value = \"@unifiedPermissionValidator.hasModifyNamespacePermission(#appId, #env, #clusterName, #namespaceName)\")\n  @PostMapping(\n      value = \"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge\")\n  @ApolloAuditLog(type = OpType.UPDATE, name = \"NamespaceBranch.merge\")\n  public ReleaseDTO merge(@PathVariable String appId, @PathVariable String env,\n      @PathVariable String clusterName, @PathVariable String namespaceName,\n      @PathVariable String branchName,\n      @RequestParam(value = \"deleteBranch\", defaultValue = \"true\") boolean deleteBranch,\n      @RequestBody NamespaceReleaseModel model) {\n\n    if (model.isEmergencyPublish() && !portalConfig.isEmergencyPublishAllowed(Env.valueOf(env))) {\n      throw new BadRequestException(\"Env: %s is not supported emergency publish now\", env);\n    }\n\n    ReleaseDTO createdRelease = namespaceBranchService.merge(appId, Env.valueOf(env), clusterName,\n        namespaceName, branchName, model.getReleaseTitle(), model.getReleaseComment(),\n        model.isEmergencyPublish(), deleteBranch, userInfoHolder.getUser().getUserId());\n\n    ConfigPublishEvent event = ConfigPublishEvent.instance();\n    event.withAppId(appId).withCluster(clusterName).withNamespace(namespaceName)\n        .withReleaseId(createdRelease.getId()).setMergeEvent(true).setEnv(Env.valueOf(env));\n\n    publisher.publishEvent(event);\n\n    return createdRelease;\n  }\n\n\n  @GetMapping(\n      value = \"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules\")","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java#L123-L159","documentation":"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.","triggerScenarios":"POST .../branches/{branchName}/merge with emergencyPublish=true for an env that is not on the portal's emergency-publish allowlist (portal config emergencyPublish.supportedEnvs).","commonSituations":"Prod is excluded from emergency publish by policy; config not updated after adding a new env; a script reusing emergencyPublish=true across all envs.","solutions":["Do not set emergencyPublish=true for envs not in the allowlist; submit a normal merge for those.","If the env should support it, add it to portal's emergency publish supportedEnvs config.","Gate the flag by env in your automation (see validationCode).","Confirm the env name spelling matches an allowlisted entry."],"exampleFix":"// before\nmodel.setEmergencyPublish(true);  // sent for PROD -> 400\n\n// after\nmodel.setEmergencyPublish(emergencyAllowedEnvs.contains(env));","handlingStrategy":"validation","validationCode":"// Only request emergency publish for allowlisted envs; fall back to normal merge.\nboolean emergency = model.isEmergencyPublish()\n    && emergencyAllowedEnvs.contains(env.toUpperCase(Locale.ROOT));\nmodel.setEmergencyPublish(emergency);\n// if emergency==false here, the merge proceeds as a normal gray merge","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a client-side copy of portalConfig emergency-publish supportedEnvs in sync.","Default emergencyPublish to false; set true only for allowlisted envs.","On a 400, retry the merge as a normal (non-emergency) publish.","Update the allowlist when envs are added/removed."],"tags":["emergency-publish","merge","validation","branch","bad-request"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}