{"record":{"id":"a1c8fb24ef48851a","repo":"apolloconfig/apollo","slug":"the-app-does-not-exist-in-the-specified-environmen-a1c8fb","errorCode":null,"errorMessage":"The app does not exist in the specified environment and cluster.","messagePattern":"The app does not exist in the specified environment and cluster\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java","lineNumber":175,"sourceCode":"      LOGGER.info(\"Import data. app = {}, appns = {}, cluster = {}, namespace = {}\",\n          toImportApps.size(), toImportAppNSs.size(), toImportClusters.size(), toImportNSs.size());\n\n      doImport(importEnvs, toImportApps, toImportAppNSs, toImportClusters, toImportNSs, operator);\n\n    } catch (Exception e) {\n      LOGGER.error(\"import config error.\", e);\n      throw new ServiceException(\"import config error.\", e);\n    }\n  }\n\n  /**\n   * import all configurations of an application in a specified environment and cluster\n   */\n  public void importAppConfigFromZipFile(String appId, Env env, String clusterName,\n      ZipInputStream dataZip, boolean ignoreConflictNamespace, String operator) throws IOException {\n    ClusterDTO clusterDTO = clusterService.loadCluster(appId, env, clusterName);\n    if (clusterDTO == null) {\n      throw new BadRequestException(\n          \"The app does not exist in the specified environment and cluster.\");\n    }\n\n    List<ImportNamespaceData> toImportNSs = Lists.newArrayList();\n    ZipEntry entry;\n    while ((entry = dataZip.getNextEntry()) != null) {\n      if (entry.isDirectory()) {\n        continue;\n      }\n\n      // file.path format :\n      // ${appId}/${env}/${appId}+${cluster}+${namespaceName}\n      String filePath = entry.getName();\n      String content = readContent(dataZip);\n      if (content == null) {\n        throw new BadRequestException(\"Failed to read file content.\");\n      }\n      String[] info = filePath.replace('\\\\', '/').split(\"/\");","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java#L157-L193","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the appId, env, and clusterName exist in the target environment by checking the cluster list via the portal UI or API.","Ensure the app has been created and deployed to the target environment before importing.","Confirm the clusterName is correct — use 'default' if the app uses the default cluster.","Check that the env name matches exactly (case-sensitive in some code paths)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the cluster exists before importing\nClusterDTO cluster = clusterService.loadCluster(appId, env, clusterName);\nif (cluster == null) {\n  throw new IllegalArgumentException(\n    String.format(\"Cluster %s not found in env %s for app %s\", clusterName, env, appId));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always verify the target app/cluster/env exists before calling importAppConfigFromZipFile.","Create the app and deploy it to the target environment before importing configs.","Use the exact clusterName (typically 'default') from the portal UI."],"tags":["apollo-portal","config-import","cluster","bad-request","validation"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}