{"record":{"id":"7f31fc3bf548d46e","repo":"apolloconfig/apollo","slug":"the-configuration-to-be-imported-is-empty","errorCode":null,"errorMessage":"The configuration to be imported is empty.","messagePattern":"The configuration to be imported is empty\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java","lineNumber":210,"sourceCode":"      }\n      String[] info = filePath.replace('\\\\', '/').split(\"/\");\n      if (info.length != 3) {\n        throw new BadRequestException(\"Invalid file path in ZIP.\");\n      }\n      String fileName = info[2];\n      String fileNamePrefix = String.format(\"%s+%s+\", appId, clusterName);\n\n      if (!info[0].equals(appId) || !info[1].equalsIgnoreCase(env.getName())\n          || !fileName.startsWith(fileNamePrefix)) {\n        throw new BadRequestException(\"The content of the file to be imported is incorrect.\");\n      }\n      if (!fileName.endsWith(ConfigFileUtils.CLUSTER_METADATA_FILE_SUFFIX)) {\n        toImportNSs.add(new ImportNamespaceData(env, fileName, content, ignoreConflictNamespace));\n      }\n    }\n\n    if (CollectionUtils.isEmpty(toImportNSs)) {\n      throw new BadRequestException(\"The configuration to be imported is empty.\");\n    }\n\n    try {\n      LOGGER.info(\"Import namespace. namespace = {}\", toImportNSs.size());\n      doImport(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(),\n          Lists.newArrayList(), toImportNSs, operator);\n    } catch (Exception e) {\n      LOGGER.error(\"import app config error.\", e);\n      throw new ServiceException(\"import app config error.\", e);\n    }\n  }\n\n  private void doImport(List<Env> importEnvs, List<String> toImportApps,\n      List<String> toImportAppNSs, List<ImportClusterData> toImportClusters,\n      List<ImportNamespaceData> toImportNSs, String operator) throws InterruptedException {\n    LOGGER.info(\"Start to import app. size = {}\", toImportApps.size());\n\n    long startTime = System.currentTimeMillis();","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsImportService.java#L192-L228","documentation":"Thrown as a BadRequestException by ConfigsImportService.importAppConfigFromZipFile() when after iterating all zip entries, the toImportNSs list is empty (checked via CollectionUtils.isEmpty). This means no valid namespace configuration entries were found — all entries were either cluster metadata files or filtered out. The import has nothing to apply.","triggerScenarios":"Importing a zip that contains only cluster metadata files (ending with CLUSTER_METADATA_FILE_SUFFIX) and no actual namespace config files. Or a zip where all entries were directory entries or didn't pass the path/content checks, leaving zero ImportNamespaceData objects.","commonSituations":"Zip exported with only cluster info but no namespace configs; zip is essentially empty of importable namespace data; user selected the wrong file; export was incomplete and only wrote metadata files.","solutions":["Verify the zip contains actual namespace configuration files, not just cluster metadata.","Re-export the app configuration ensuring namespace files are included.","Inspect the zip contents (unzip -l) and confirm namespace config files are present.","If importing only cluster metadata, use the appropriate import method instead of importAppConfigFromZipFile."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check that the zip contains at least one namespace config file\nboolean hasNamespaceFile = false;\ntry (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) {\n  ZipEntry entry;\n  while ((entry = zis.getNextEntry()) != null) {\n    if (!entry.isDirectory() && !entry.getName().endsWith(\".cluster.metadata\")) {\n      hasNamespaceFile = true;\n      break;\n    }\n  }\n}\nif (!hasNamespaceFile) {\n  throw new IllegalArgumentException(\"Zip contains no namespace configuration files\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the export included namespace configs, not just cluster metadata.","Re-export with namespace files included if the zip is metadata-only.","Inspect zip contents before importing to confirm namespace files exist."],"tags":["apollo-portal","config-import","zip","bad-request","empty-data"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}