{"record":{"id":"2c14dd6661a1c2d1","repo":"apolloconfig/apollo","slug":"import-app-configs-failed-s","errorCode":null,"errorMessage":"import app configs failed: %s","messagePattern":"import app configs failed: (.+?)","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java","lineNumber":661,"sourceCode":"    NamespaceBO namespaceBO =\n        namespaceService.loadNamespaceBO(appId, targetEnv, clusterName, namespaceName, true, false);\n    String configFileContent = NamespaceBOUtils.convert2configFileContent(namespaceBO);\n    return resourceResponse(fileName, configFileContent.getBytes(StandardCharsets.UTF_8));\n  }\n\n  @Override\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isAppAdmin(#appId)\")\n  public ResponseEntity<Void> importAppConfig(String appId, String env, String clusterName,\n      String conflictAction, MultipartFile file) {\n    requirePortalUserRequest();\n    String resolvedConflictAction = resolveConflictAction(conflictAction);\n    Env targetEnv = parseEnv(env);\n    try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {\n      configsImportService.importAppConfigFromZipFile(appId, targetEnv, clusterName, zipInputStream,\n          CONFLICT_ACTION_IGNORE.equals(resolvedConflictAction), currentUserId());\n      return ResponseEntity.ok().build();\n    } catch (IOException e) {\n      throw new BadRequestException(\"import app configs failed: %s\", e.getMessage());\n    }\n  }\n\n  @Override\n  public ResponseEntity<Object> searchAppsByAppIdOrName(String query, Integer page, Integer size) {\n    requirePortalUserRequest();\n    Pageable pageable = pageable(page, size);\n    if (org.springframework.util.StringUtils.isEmpty(query)) {\n      return ResponseEntity.ok(appService.findAll(pageable));\n    }\n\n    PageDTO<App> appPage = appService.searchByAppIdOrAppName(query, pageable);\n    if (appPage.hasContent()) {\n      return ResponseEntity.ok(appPage);\n    }\n\n    if (!portalConfig.supportSearchByItem()) {\n      return ResponseEntity.ok(new PageDTO<>(Collections.emptyList(), pageable, 0));","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L643-L679","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: uploading a properties file instead of zip\ncurl -F 'file=app.properties' ...\n\n// after: use the zip from exportAppConfig\ncurl -F 'file=app_config_export.zip' ...","handlingStrategy":"try-catch","validationCode":"// Validate ZIP before uploading for app import\ntry (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) {\n  ZipEntry entry;\n  while ((entry = zis.getNextEntry()) != null) { /* valid */ }\n} catch (IOException e) {\n  throw new IllegalArgumentException(\"Invalid ZIP for import\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  importAppConfig(appId, env, cluster, conflictAction, file);\n} catch (BadRequestException e) {\n  if (e.getMessage().contains(\"import app configs failed\")) {\n    // check underlying IOException, re-export and retry\n  }\n}","preventionTips":["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."],"tags":["io","openapi","bad-request","import","zip","app-admin","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}