{"record":{"id":"27bb9e718fd8df89","repo":"apolloconfig/apollo","slug":"import-configs-failed-s","errorCode":null,"errorMessage":"import configs failed: %s","messagePattern":"import 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":604,"sourceCode":"    return exportZipResource(filename,\n        outputStream -> configsExportService.exportData(outputStream, exportEnvs),\n        \"export configs failed\");\n  }\n\n  @Override\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isSuperAdmin()\")\n  public ResponseEntity<Void> importAllConfigs(String envs, String conflictAction,\n      MultipartFile file) {\n    requirePortalUserRequest();\n    String resolvedConflictAction = resolveConflictAction(conflictAction);\n    List<Env> importEnvs = Splitter.on(ENV_SEPARATOR).splitToList(envs).stream().map(this::parseEnv)\n        .collect(Collectors.toList());\n    try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream())) {\n      configsImportService.importDataFromZipFile(importEnvs, zipInputStream,\n          CONFLICT_ACTION_IGNORE.equals(resolvedConflictAction), currentUserId());\n      return ResponseEntity.ok().build();\n    } catch (IOException e) {\n      throw new BadRequestException(\"import configs failed: %s\", e.getMessage());\n    }\n  }\n\n  @Override\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isAppAdmin(#appId)\")\n  public ResponseEntity<Void> checkExportAppConfig(String appId, String env, String clusterName) {\n    requirePortalUserRequest();\n    return ResponseEntity.ok().build();\n  }\n\n  @Override\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isAppAdmin(#appId)\")\n  public ResponseEntity<Resource> exportAppConfig(String appId, String env, String clusterName) {\n    requirePortalUserRequest();\n    Env targetEnv = parseEnv(env);\n    String filename = String.format(\"%s+%s+%s+%s.zip\", appId, env, clusterName,\n        DateFormatUtils.format(new Date(), \"yyyy_MMdd_HH_mm_ss\"));\n    return exportZipResource(filename, outputStream -> configsExportService","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L586-L622","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the uploaded file is a valid ZIP archive, ideally one produced by the matching exportAllConfigs endpoint.","Check the multipart form field name and Content-Type (multipart/form-data).","If the file was transferred or compressed differently, re-export from Apollo and re-import without modification.","Inspect the underlying IOException message (appended after the colon) for the exact read failure."],"exampleFix":"// before: uploading a non-zip file or corrupted zip\ncurl -F 'file=configs.properties' ...\n\n// after: upload a valid zip exported from Apollo\ncurl -F 'file=apollo_config_export_2025_0101_00_00_00.zip' ...","handlingStrategy":"try-catch","validationCode":"// Validate the file is a valid ZIP before uploading\ntry (ZipFile zf = new ZipFile(uploadedFile)) {\n  // zip is valid\n} catch (IOException e) {\n  throw new IllegalArgumentException(\"Uploaded file is not a valid ZIP\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  importAllConfigs(envs, conflictAction, file);\n} catch (BadRequestException e) {\n  if (e.getMessage().contains(\"import configs failed\")) {\n    // log the IOException detail, re-export from source env, retry\n  }\n}","preventionTips":["Only upload ZIP files produced by Apollo's export endpoints.","Validate the ZIP integrity client-side before uploading.","Keep export/import within the same Apollo version to avoid format mismatches."],"tags":["io","openapi","bad-request","import","zip","super-admin","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}