apolloconfig/apollo · error · ServiceException
Write namespace error. {}
Error message
Write namespace error. {} What it means
Thrown by ConfigsExportService when writing a namespace configuration file (properties/xml/yml etc.) into the export ZipOutputStream fails with an IOException. This occurs in the configBO consumer that iterates over ConfigBO objects, generates the file path via ConfigFileUtils, and calls writeToZip. The ServiceException wraps the IOException and terminates the export.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ConfigsExportService.java:306
synchronized (zipOutputStream) {
String appId = configBO.getAppId();
String clusterName = configBO.getClusterName();
String namespace = configBO.getNamespace();
String configFileContent = configBO.getConfigFileContent();
ConfigFileFormat configFileFormat = configBO.getFormat();
String configFileName =
ConfigFileUtils.toFilename(appId, clusterName, namespace, configFileFormat);
String filePath = ignoreUserDir
? ConfigFileUtils.genNamespacePathIgnoreUser(appId, configBO.getEnv(), configFileName)
: ConfigFileUtils.genNamespacePath(configBO.getOwnerName(), appId, configBO.getEnv(),
configFileName);
writeToZip(filePath, configFileContent, zipOutputStream);
}
} catch (IOException e) {
logger.error("Write error. {}", configBO);
throw new ServiceException("Write namespace error. {}", e);
}
};
configBOStream.forEach(configBOConsumer);
}
private void writeClusterInfoToZip(Env env, App app, List<ClusterDTO> exportClusters,
ZipOutputStream zipOutputStream) {
final Consumer<ClusterDTO> clusterConsumer = cluster -> {
try {
synchronized (zipOutputStream) {
String fileName = ConfigFileUtils.genClusterInfoPath(app, env, cluster);
String content = gson.toJson(cluster);
writeToZip(fileName, content, zipOutputStream);
}
} catch (IOException e) {
logger.error("Write error. {}", cluster);View on GitHub (pinned to d95fc18d11)
Solutions
- Check the underlying IOException in portal logs — the preceding 'Write error. {configBO}' line identifies which namespace failed.
- Ensure the HTTP client/proxy (nginx, load balancer) allows sufficient response time and body size for large exports.
- Verify the OutputStream passed to the export method is open and not prematurely closed by a filter or interceptor.
- If exporting a specific app, reduce scope or export per-environment to avoid streaming too much data at once.
Defensive patterns
Strategy: try-catch
Try / catch
try {
configsExportService.exportNamespaces(zipOutputStream, configBOs);
} catch (ServiceException e) {
log.error("Namespace export failed at I/O level", e);
// surface a user-friendly message about export interruption
throw e;
} Prevention
- Ensure the response OutputStream stays open for the entire export duration.
- Test exports with a small number of namespaces first to validate the pipeline.
- Monitor network stability between client and portal during large exports.
When it happens
Trigger: Exporting namespace configs where writeToZip() hits an I/O error: the OutputStream backing the response is closed, the zip entry path is invalid, or the stream was finished. The forEach over configBOStream drives sequential writes under no external synchronization beyond the method-level flow.
Common situations: Large number of namespaces causing the response to exceed proxy timeout; client disconnect during export; the generated file path contains characters invalid for ZipEntry names; disk pressure on the server.
Related errors
- export app config error
- Write app error. {}
- Write error. {}
- export config error
- import configs failed: %s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/aaa64dfeb72db0dc.
Report an issue: GitHub.