apolloconfig/apollo · warning · BadRequestException

The app does not exist in the specified environment and…

Error message

The app does not exist in the specified environment and cluster.

What it means

Thrown by ConfigsExportService.exportAppConfigByEnvAndCluster when the app exists but clusterService.loadCluster(appId, env, clusterName) returns null — the app has no presence in the specified environment/cluster. BadRequestException → HTTP 400. Indicates an env/cluster mismatch rather than a missing app.

Solutions

  1. Confirm the app exists in the target env/cluster via clusterService.loadCluster before exporting.
  2. Use a cluster name that actually exists for the app in that env (commonly 'default').
  3. Ensure the env is active and the app has been pushed to it.

Example fix

// before
exportAppConfigByEnvAndCluster(appId, env, clusterName, out);

// after
if (clusterService.loadCluster(appId, env, clusterName) == null) {
  throw new IllegalArgumentException("app not deployed to " + env + "/" + clusterName);
}
exportAppConfigByEnvAndCluster(appId, env, clusterName, out);
Defensive patterns

Strategy: validation

Validate before calling

if (clusterService.loadCluster(appId, env, clusterName) == null) {
  return ResponseEntity.badRequest().body("app not deployed to " + env + "/" + clusterName);
}

Type guard

boolean appDeployedToEnvCluster(String appId, Env env, String cluster, ClusterService svc) {
  return svc.loadCluster(appId, env, cluster) != null;
}

Prevention

When it happens

Trigger: Exporting an app into an env or cluster where it was never deployed/created; clusterName typo; env not active for this app.

Common situations: App created in DEV/PRO only but export requested for UAT; cluster name default ('default') vs custom mismatch; env not enabled in portalSettings; new env not yet provisioned for the app.

Related errors


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

Appendix: source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java:121

  /**
   * Export all configurations of an application in a specified environment and cluster
   * <p>
   * File Struts:
   * <p>
   *
   * List<App> -> List<Env> -> List<Namespace>
   *
   * @param outputStream network file download stream to user
   */
  public void exportAppConfigByEnvAndCluster(String appId, Env env, String clusterName,
      OutputStream outputStream) {
    App app = appService.load(appId);
    if (app == null) {
      throw new BadRequestException("App not found: " + appId);
    }
    ClusterDTO cluster = clusterService.loadCluster(appId, env, clusterName);
    if (cluster == null) {
      throw new BadRequestException(
          "The app does not exist in the specified environment and cluster.");
    }

    try (final ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {
      try {
        this.exportNamespaces(env, app, cluster, zipOutputStream, true);
      } catch (BadRequestException badRequestException) {
        // ignore
      } catch (Exception e) {
        logger.error("export namespace error. appId = {}, env = {}, cluster = {}", app.getAppId(),
            env.getName(), cluster.getName(), e);
      }
    } catch (IOException e) {
      logger.error("export app config error", e);
      throw new ServiceException("export app config error", e);
    }
  }

View on GitHub (pinned to d95fc18d11)