apolloconfig/apollo · error · BadRequestException

The app does not exist in the specified environment and clus

Error message

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

What it means

Thrown as a BadRequestException by ConfigsImportService.importAppConfigFromZipFile() when clusterService.loadCluster() returns null for the given appId/env/clusterName combination. This is a precondition check: the target application and cluster must already exist in the specified environment before importing configurations into it.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java:175

      LOGGER.info("Import data. app = {}, appns = {}, cluster = {}, namespace = {}",
          toImportApps.size(), toImportAppNSs.size(), toImportClusters.size(), toImportNSs.size());

      doImport(importEnvs, toImportApps, toImportAppNSs, toImportClusters, toImportNSs, operator);

    } catch (Exception e) {
      LOGGER.error("import config error.", e);
      throw new ServiceException("import config error.", e);
    }
  }

  /**
   * import all configurations of an application in a specified environment and cluster
   */
  public void importAppConfigFromZipFile(String appId, Env env, String clusterName,
      ZipInputStream dataZip, boolean ignoreConflictNamespace, String operator) throws IOException {
    ClusterDTO clusterDTO = clusterService.loadCluster(appId, env, clusterName);
    if (clusterDTO == null) {
      throw new BadRequestException(
          "The app does not exist in the specified environment and cluster.");
    }

    List<ImportNamespaceData> toImportNSs = Lists.newArrayList();
    ZipEntry entry;
    while ((entry = dataZip.getNextEntry()) != null) {
      if (entry.isDirectory()) {
        continue;
      }

      // file.path format :
      // ${appId}/${env}/${appId}+${cluster}+${namespaceName}
      String filePath = entry.getName();
      String content = readContent(dataZip);
      if (content == null) {
        throw new BadRequestException("Failed to read file content.");
      }
      String[] info = filePath.replace('\\', '/').split("/");

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Verify the appId, env, and clusterName exist in the target environment by checking the cluster list via the portal UI or API.
  2. Ensure the app has been created and deployed to the target environment before importing.
  3. Confirm the clusterName is correct — use 'default' if the app uses the default cluster.
  4. Check that the env name matches exactly (case-sensitive in some code paths).
Defensive patterns

Strategy: validation

Validate before calling

// Verify the cluster exists before importing
ClusterDTO cluster = clusterService.loadCluster(appId, env, clusterName);
if (cluster == null) {
  throw new IllegalArgumentException(
    String.format("Cluster %s not found in env %s for app %s", clusterName, env, appId));
}

Prevention

When it happens

Trigger: Calling importAppConfigFromZipFile with an appId, env, or clusterName that does not exist in the target environment's config service. The loadCluster API call to the admin service returns null because no cluster matches the parameters.

Common situations: Importing into the wrong environment (e.g., PROD zip into DEV); typos in appId or clusterName; the app was created in the portal but not yet deployed to the target env's admin service; env name case mismatch.

Related errors


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