{"record":{"id":"36e3e26855e9fa4c","repo":"apolloconfig/apollo","slug":"s-s","errorCode":null,"errorMessage":"%s: %s","messagePattern":"%s: %s","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java","lineNumber":842,"sourceCode":"  }\n\n  private ResponseEntity<Resource> resourceResponse(String filename, byte[] content) {\n    return resourceResponse(filename, new ByteArrayResource(content), content.length);\n  }\n\n  private ResponseEntity<Resource> exportZipResource(String filename, OutputStreamExporter exporter,\n      String errorMessage) {\n    Path tempFile = null;\n    try {\n      tempFile = Files.createTempFile(\"apollo-config-export-\", \".zip\");\n      try (OutputStream outputStream = Files.newOutputStream(tempFile)) {\n        exporter.export(outputStream);\n      }\n      return resourceResponse(filename, new DeleteOnCloseFileResource(tempFile),\n          Files.size(tempFile));\n    } catch (IOException e) {\n      deleteQuietly(tempFile);\n      throw new BadRequestException(\"%s: %s\", errorMessage, e.getMessage());\n    } catch (RuntimeException e) {\n      deleteQuietly(tempFile);\n      throw e;\n    }\n  }\n\n  private interface OutputStreamExporter {\n\n    void export(OutputStream outputStream);\n  }\n\n  private ResponseEntity<Resource> resourceResponse(String filename, Resource resource,\n      long contentLength) {\n    return ResponseEntity.ok()\n        .header(HttpHeaders.CONTENT_DISPOSITION, \"attachment;filename=\" + filename)\n        .contentType(MediaType.APPLICATION_OCTET_STREAM).contentLength(contentLength)\n        .body(resource);\n  }","sourceCodeStart":824,"sourceCodeEnd":860,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L824-L860","documentation":"Thrown by the generic exportZipResource helper when an IOException occurs while creating the temp file, writing the ZIP output stream, or measuring the final file size during a config export operation. The message formats as '<errorMessage>: <IOException detail>' where errorMessage is supplied by the caller (e.g. 'export app configs failed'). The temp file is cleaned up on failure.","triggerScenarios":"Any zip-export operation (exportAllConfigs, exportAppConfig, etc.) that hits an IOException during temp-file creation, stream writing, or size measurement.","commonSituations":"The server's temp directory is full or not writable; disk space is exhausted; the exporter lambda throws during serialization; or an OS-level I/O error interrupts the stream write.","solutions":["Check that the server's java.io.tmpdir has sufficient disk space and write permissions.","Review the IOException detail in the error message for the root cause.","If the export data is very large, consider exporting per-environment or per-app to reduce temp-file size.","Verify the underlying export service (configsExportService) is healthy and not failing on data serialization."],"exampleFix":"// before: temp dir full, export fails silently\n// Check: df -h /tmp\n\n// after: ensure writable temp dir with space\njava -Djava.io.tmpdir=/data/tmp -jar apollo-portal.jar","handlingStrategy":"try-catch","validationCode":"// Check temp dir writability and disk space before export\nPath tmp = Paths.get(System.getProperty(\"java.io.tmpdir\"));\nif (!Files.isWritable(tmp)) {\n  throw new IllegalStateException(\"Temp dir not writable: \" + tmp);\n}","typeGuard":null,"tryCatchPattern":"try {\n  exportZipResource(filename, exporter, errorMessage);\n} catch (BadRequestException e) {\n  if (e.getMessage().contains(errorMessage)) {\n    // check disk space, clean temp, retry or report infra issue\n  }\n}","preventionTips":["Monitor free disk space on the portal server's temp directory.","Set java.io.tmpdir to a volume with adequate space.","Schedule periodic cleanup of stale apollo-config-export temp files."],"tags":["io","openapi","bad-request","export","zip","temp-file","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}