apolloconfig/apollo · error · BadRequestException
%s: %s
Error message
%s: %s
What it means
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.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:842
}
private ResponseEntity<Resource> resourceResponse(String filename, byte[] content) {
return resourceResponse(filename, new ByteArrayResource(content), content.length);
}
private ResponseEntity<Resource> exportZipResource(String filename, OutputStreamExporter exporter,
String errorMessage) {
Path tempFile = null;
try {
tempFile = Files.createTempFile("apollo-config-export-", ".zip");
try (OutputStream outputStream = Files.newOutputStream(tempFile)) {
exporter.export(outputStream);
}
return resourceResponse(filename, new DeleteOnCloseFileResource(tempFile),
Files.size(tempFile));
} catch (IOException e) {
deleteQuietly(tempFile);
throw new BadRequestException("%s: %s", errorMessage, e.getMessage());
} catch (RuntimeException e) {
deleteQuietly(tempFile);
throw e;
}
}
private interface OutputStreamExporter {
void export(OutputStream outputStream);
}
private ResponseEntity<Resource> resourceResponse(String filename, Resource resource,
long contentLength) {
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename)
.contentType(MediaType.APPLICATION_OCTET_STREAM).contentLength(contentLength)
.body(resource);
}View on GitHub (pinned to d95fc18d11)
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.
Example fix
// before: temp dir full, export fails silently // Check: df -h /tmp // after: ensure writable temp dir with space java -Djava.io.tmpdir=/data/tmp -jar apollo-portal.jar
Defensive patterns
Strategy: try-catch
Validate before calling
// Check temp dir writability and disk space before export
Path tmp = Paths.get(System.getProperty("java.io.tmpdir"));
if (!Files.isWritable(tmp)) {
throw new IllegalStateException("Temp dir not writable: " + tmp);
} Try / catch
try {
exportZipResource(filename, exporter, errorMessage);
} catch (BadRequestException e) {
if (e.getMessage().contains(errorMessage)) {
// check disk space, clean temp, retry or report infra issue
}
} Prevention
- 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.
When it happens
Trigger: Any zip-export operation (exportAllConfigs, exportAppConfig, etc.) that hits an IOException during temp-file creation, stream writing, or size measurement.
Common situations: 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.
Related errors
- import configs failed: %s
- import app configs failed: %s
- import namespace items failed: %s
- Failed to read file content.
- create namespace failed for: %s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/36e3e26855e9fa4c.
Report an issue: GitHub.