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
- Re-export the app config ZIP from a known-good environment and upload that file unchanged.
- Verify the multipart form-data field name and that the file content-type is being sent correctly.
- Read the IOException detail in the error message to identify the specific read failure (e.g. 'Not in GZIP format', 'invalid entry size').
- 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
- Use export ZIPs from the same Apollo version for import.
- Validate the ZIP structure client-side before uploading.
- Ensure the multipart max-file-size allows your ZIP.
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
- import configs failed: %s
- import namespace items failed: %s
- %s: %s
- ConflictAction is incorrect.
- Failed to read file content.
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/2c14dd6661a1c2d1.
Report an issue: GitHub.