apolloconfig/apollo · warning · BadRequestException

The configuration to be imported is empty.

Error message

The configuration to be imported is empty.

What it means

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.

Solutions

  1. Verify the zip contains actual namespace configuration files, not just cluster metadata.
  2. Re-export the app configuration ensuring namespace files are included.
  3. Inspect the zip contents (unzip -l) and confirm namespace config files are present.
  4. If importing only cluster metadata, use the appropriate import method instead of importAppConfigFromZipFile.
Defensive patterns

Strategy: validation

Validate before calling

// Check that the zip contains at least one namespace config file
boolean hasNamespaceFile = false;
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) {
  ZipEntry entry;
  while ((entry = zis.getNextEntry()) != null) {
    if (!entry.isDirectory() && !entry.getName().endsWith(".cluster.metadata")) {
      hasNamespaceFile = true;
      break;
    }
  }
}
if (!hasNamespaceFile) {
  throw new IllegalArgumentException("Zip contains no namespace configuration files");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

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

      }
      String[] info = filePath.replace('\\', '/').split("/");
      if (info.length != 3) {
        throw new BadRequestException("Invalid file path in ZIP.");
      }
      String fileName = info[2];
      String fileNamePrefix = String.format("%s+%s+", appId, clusterName);

      if (!info[0].equals(appId) || !info[1].equalsIgnoreCase(env.getName())
          || !fileName.startsWith(fileNamePrefix)) {
        throw new BadRequestException("The content of the file to be imported is incorrect.");
      }
      if (!fileName.endsWith(ConfigFileUtils.CLUSTER_METADATA_FILE_SUFFIX)) {
        toImportNSs.add(new ImportNamespaceData(env, fileName, content, ignoreConflictNamespace));
      }
    }

    if (CollectionUtils.isEmpty(toImportNSs)) {
      throw new BadRequestException("The configuration to be imported is empty.");
    }

    try {
      LOGGER.info("Import namespace. namespace = {}", toImportNSs.size());
      doImport(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(),
          Lists.newArrayList(), toImportNSs, operator);
    } catch (Exception e) {
      LOGGER.error("import app config error.", e);
      throw new ServiceException("import app config error.", e);
    }
  }

  private void doImport(List<Env> importEnvs, List<String> toImportApps,
      List<String> toImportAppNSs, List<ImportClusterData> toImportClusters,
      List<ImportNamespaceData> toImportNSs, String operator) throws InterruptedException {
    LOGGER.info("Start to import app. size = {}", toImportApps.size());

    long startTime = System.currentTimeMillis();

View on GitHub (pinned to d95fc18d11)