apolloconfig/apollo · error · BadRequestException

import app configs failed: %s

Error message

import app configs failed: %s

What it means

Thrown in importAppConfig when an IOException occurs while reading the uploaded ZIP file during app-scoped config import for a specific env/cluster. The message embeds the underlying IOException detail. This endpoint requires app-admin permission and expects a valid ZIP archive.

Source

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

    NamespaceBO namespaceBO =
        namespaceService.loadNamespaceBO(appId, targetEnv, clusterName, namespaceName, true, false);
    String configFileContent = NamespaceBOUtils.convert2configFileContent(namespaceBO);
    return resourceResponse(fileName, configFileContent.getBytes(StandardCharsets.UTF_8));
  }

  @Override
  @PreAuthorize(value = "@unifiedPermissionValidator.isAppAdmin(#appId)")
  public ResponseEntity<Void> importAppConfig(String appId, String env, String clusterName,
      String conflictAction, MultipartFile file) {
    requirePortalUserRequest();
    String resolvedConflictAction = resolveConflictAction(conflictAction);
    Env targetEnv = parseEnv(env);
    try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {
      configsImportService.importAppConfigFromZipFile(appId, targetEnv, clusterName, zipInputStream,
          CONFLICT_ACTION_IGNORE.equals(resolvedConflictAction), currentUserId());
      return ResponseEntity.ok().build();
    } catch (IOException e) {
      throw new BadRequestException("import app configs failed: %s", e.getMessage());
    }
  }

  @Override
  public ResponseEntity<Object> searchAppsByAppIdOrName(String query, Integer page, Integer size) {
    requirePortalUserRequest();
    Pageable pageable = pageable(page, size);
    if (org.springframework.util.StringUtils.isEmpty(query)) {
      return ResponseEntity.ok(appService.findAll(pageable));
    }

    PageDTO<App> appPage = appService.searchByAppIdOrAppName(query, pageable);
    if (appPage.hasContent()) {
      return ResponseEntity.ok(appPage);
    }

    if (!portalConfig.supportSearchByItem()) {
      return ResponseEntity.ok(new PageDTO<>(Collections.emptyList(), pageable, 0));

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Re-export the app config ZIP from a known-good environment and upload that file unchanged.
  2. Verify the multipart form-data field name and that the file content-type is being sent correctly.
  3. Read the IOException detail in the error message to identify the specific read failure (e.g. 'Not in GZIP format', 'invalid entry size').
  4. If the ZIP is large, ensure it is not exceeding the server's multipart max-file-size setting.

Example fix

// before: uploading a properties file instead of zip
curl -F 'file=app.properties' ...

// after: use the zip from exportAppConfig
curl -F 'file=app_config_export.zip' ...
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate ZIP before uploading for app import
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) {
  ZipEntry entry;
  while ((entry = zis.getNextEntry()) != null) { /* valid */ }
} catch (IOException e) {
  throw new IllegalArgumentException("Invalid ZIP for import", e);
}

Try / catch

try {
  importAppConfig(appId, env, cluster, conflictAction, file);
} catch (BadRequestException e) {
  if (e.getMessage().contains("import app configs failed")) {
    // check underlying IOException, re-export and retry
  }
}

Prevention

When it happens

Trigger: An app admin uploads a ZIP file to import app configs for a specific env and cluster, but ZipInputStream encounters a read error or the file is malformed.

Common situations: The uploaded ZIP is corrupted or is not a ZIP at all; the multipart upload was interrupted; the file's internal structure does not match the expected export format; or the ZIP contains entries that cannot be deserialized.

Related errors


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