{"record":{"id":"6ac3c987ab45044f","repo":"apolloconfig/apollo","slug":"the-app-does-not-exist-in-the-specified-environmen","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":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java","lineNumber":121,"sourceCode":"  /**\n   * Export all configurations of an application in a specified environment and cluster\n   * <p>\n   * File Struts:\n   * <p>\n   *\n   * List<App> -> List<Env> -> List<Namespace>\n   *\n   * @param outputStream network file download stream to user\n   */\n  public void exportAppConfigByEnvAndCluster(String appId, Env env, String clusterName,\n      OutputStream outputStream) {\n    App app = appService.load(appId);\n    if (app == null) {\n      throw new BadRequestException(\"App not found: \" + appId);\n    }\n    ClusterDTO cluster = clusterService.loadCluster(appId, env, clusterName);\n    if (cluster == null) {\n      throw new BadRequestException(\n          \"The app does not exist in the specified environment and cluster.\");\n    }\n\n    try (final ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {\n      try {\n        this.exportNamespaces(env, app, cluster, zipOutputStream, true);\n      } catch (BadRequestException badRequestException) {\n        // ignore\n      } catch (Exception e) {\n        logger.error(\"export namespace error. appId = {}, env = {}, cluster = {}\", app.getAppId(),\n            env.getName(), cluster.getName(), e);\n      }\n    } catch (IOException e) {\n      logger.error(\"export app config error\", e);\n      throw new ServiceException(\"export app config error\", e);\n    }\n  }\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java#L103-L139","documentation":"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.","triggerScenarios":"Exporting an app into an env or cluster where it was never deployed/created; clusterName typo; env not active for this app.","commonSituations":"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.","solutions":["Confirm the app exists in the target env/cluster via clusterService.loadCluster before exporting.","Use a cluster name that actually exists for the app in that env (commonly 'default').","Ensure the env is active and the app has been pushed to it."],"exampleFix":"// before\nexportAppConfigByEnvAndCluster(appId, env, clusterName, out);\n\n// after\nif (clusterService.loadCluster(appId, env, clusterName) == null) {\n  throw new IllegalArgumentException(\"app not deployed to \" + env + \"/\" + clusterName);\n}\nexportAppConfigByEnvAndCluster(appId, env, clusterName, out);","handlingStrategy":"validation","validationCode":"if (clusterService.loadCluster(appId, env, clusterName) == null) {\n  return ResponseEntity.badRequest().body(\"app not deployed to \" + env + \"/\" + clusterName);\n}","typeGuard":"boolean appDeployedToEnvCluster(String appId, Env env, String cluster, ClusterService svc) {\n  return svc.loadCluster(appId, env, cluster) != null;\n}","tryCatchPattern":null,"preventionTips":["Verify the app is deployed to the target env/cluster before export.","Use the correct cluster name (commonly 'default').","Ensure the env is active and provisioned for the app."],"tags":["apollo-portal","config-export","validation","cluster","environment"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}