apolloconfig/apollo · error · BadRequestException

import configs failed: %s

Error message

import configs failed: %s

What it means

Thrown in importAllConfigs when an IOException occurs while reading or processing the uploaded ZIP file for global config import across multiple environments. The message includes the underlying IOException detail. This is a super-admin-only bulk import endpoint that expects a valid ZIP archive produced by the export feature.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:604

    return exportZipResource(filename,
        outputStream -> configsExportService.exportData(outputStream, exportEnvs),
        "export configs failed");
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isSuperAdmin()")
  public ResponseEntity<Void> importAllConfigs(String envs, String conflictAction,
      MultipartFile file) {
    requirePortalUserRequest();
    String resolvedConflictAction = resolveConflictAction(conflictAction);
    List<Env> importEnvs = Splitter.on(ENV_SEPARATOR).splitToList(envs).stream().map(this::parseEnv)
        .collect(Collectors.toList());
    try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {
      configsImportService.importDataFromZipFile(importEnvs, zipInputStream,
          CONFLICT_ACTION_IGNORE.equals(resolvedConflictAction), currentUserId());
      return ResponseEntity.ok().build();
    } catch (IOException e) {
      throw new BadRequestException("import configs failed: %s", e.getMessage());
    }
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isAppAdmin(#appId)")
  public ResponseEntity<Void> checkExportAppConfig(String appId, String env, String clusterName) {
    requirePortalUserRequest();
    return ResponseEntity.ok().build();
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isAppAdmin(#appId)")
  public ResponseEntity<Resource> exportAppConfig(String appId, String env, String clusterName) {
    requirePortalUserRequest();
    Env targetEnv = parseEnv(env);
    String filename = String.format("%s+%s+%s+%s.zip", appId, env, clusterName,
        DateFormatUtils.format(new Date(), "yyyy_MMdd_HH_mm_ss"));
    return exportZipResource(filename, outputStream -> configsExportService

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Ensure the uploaded file is a valid ZIP archive, ideally one produced by the matching exportAllConfigs endpoint.
  2. Check the multipart form field name and Content-Type (multipart/form-data).
  3. If the file was transferred or compressed differently, re-export from Apollo and re-import without modification.
  4. Inspect the underlying IOException message (appended after the colon) for the exact read failure.

Example fix

// before: uploading a non-zip file or corrupted zip
curl -F 'file=configs.properties' ...

// after: upload a valid zip exported from Apollo
curl -F 'file=apollo_config_export_2025_0101_00_00_00.zip' ...
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the file is a valid ZIP before uploading
try (ZipFile zf = new ZipFile(uploadedFile)) {
  // zip is valid
} catch (IOException e) {
  throw new IllegalArgumentException("Uploaded file is not a valid ZIP", e);
}

Try / catch

try {
  importAllConfigs(envs, conflictAction, file);
} catch (BadRequestException e) {
  if (e.getMessage().contains("import configs failed")) {
    // log the IOException detail, re-export from source env, retry
  }
}

Prevention

When it happens

Trigger: A super-admin uploads a file to the global config import endpoint that is not a valid ZIP, is corrupted, or causes a read error when ZipInputStream processes it.

Common situations: The uploaded file was not a ZIP archive (e.g. a tar.gz or raw properties file); the ZIP was truncated during upload; the file exceeds size limits causing a stream error; or the multipart file part name does not match what the endpoint expects.

Related errors


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