{"record":{"id":"0da95bd3c0b10c1c","repo":"apolloconfig/apollo","slug":"import-config-error","errorCode":null,"errorMessage":"import config error.","messagePattern":"import config error\\.","errorType":"exception","errorClass":"ServiceException","httpStatus":500,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java","lineNumber":164,"sourceCode":"              // namespace file.path format :\n              // apollo/${appId}/${env}/${appId}+${cluster}+${namespaceName}\n              toImportNSs.add(new ImportNamespaceData(Env.valueOf(env), fileName, content,\n                  ignoreConflictNamespace));\n            }\n          }\n        }\n      }\n    }\n\n    try {\n      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()) {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java#L146-L182","documentation":"Thrown by ConfigsImportService.importDataFromZipFile() as a catch-all ServiceException wrapping any Exception raised during doImport(). The doImport method runs parallel imports of apps, app namespaces, clusters, and namespaces using parallelStream and CountDownLatch. Any failure in those import sub-tasks propagates up as this generic error, logged with the full exception stack trace.","triggerScenarios":"Calling the full data import API (importDataFromZipFile) where any sub-import fails: an app already exists with conflicting data, a namespace conflict when ignoreConflictNamespace is false, the admin/config service is unreachable, or a database constraint violation occurs during parallel import.","commonSituations":"Importing a zip exported from a different Apollo environment where app/namespace IDs conflict; target env config service down; database unique constraint violation on appnamespace name; race condition in parallel import causing duplicate key.","solutions":["Examine the portal logs for the preceding 'import config error.' line which contains the full stack trace of the root cause.","If the cause is a namespace conflict, retry with ignoreConflictNamespace=true or resolve the conflict manually.","Verify all target environments in importEnvs are reachable and their config/admin services are healthy.","Check for duplicate app or appnamespace names between the zip and the target portal database."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: verify target envs are reachable and check for obvious conflicts\nfor (Env env : importEnvs) {\n  if (!envService.isEnvValid(env)) {\n    throw new IllegalStateException(\"Target env not reachable: \" + env);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  configsImportService.importDataFromZipFile(envs, zipStream, ignoreConflict, operator);\n} catch (ServiceException e) {\n  log.error(\"Full data import failed\", e);\n  if (ignoreConflict == false && e.getCause() != null) {\n    log.warn(\"Consider retrying with ignoreConflictNamespace=true after review\");\n  }\n  throw e;\n}","preventionTips":["Run a dry-run or conflict check before importing to identify duplicates.","Ensure all target environment admin/config services are healthy before import.","Back up existing configurations before a full data import.","Start with ignoreConflictNamespace=true if overwriting is intended."],"tags":["apollo-portal","config-import","zip","parallel-import","service-exception"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}