alibaba/canal · error · ServiceException
clusterId and serverId are all empty
Error message
clusterId and serverId are all empty
What it means
Thrown by CanalConfigServiceImpl when neither a valid clusterId nor a non-zero serverId is supplied. The lookup branches on clusterId first, then serverId; the else branch rejects an ambiguous/empty request.
Source
Thrown at admin/admin-web/src/main/java/com/alibaba/otter/canal/admin/service/impl/CanalConfigServiceImpl.java:50
private static final String CANAL_ADAPTER_CONFIG = "application.yml";
public CanalConfig getCanalConfig(Long clusterId, Long serverId) {
CanalConfig config = null;
if (clusterId != null && clusterId != 0) {
config = CanalConfig.find.query().where().eq("clusterId", clusterId).findOne();
} else if (serverId != null && serverId != 0) {
config = CanalConfig.find.query().where().eq("serverId", serverId).findOne();
if (config == null) {
NodeServer nodeServer = NodeServer.find.byId(serverId);
if (nodeServer != null) {
Long cid = nodeServer.getClusterId();
if (cid != null) {
config = CanalConfig.find.query().where().eq("clusterId", cid).findOne();
}
}
}
} else {
throw new ServiceException("clusterId and serverId are all empty");
}
if (config == null) {
config = new CanalConfig();
config.setName(CANAL_GLOBAL_CONFIG);
return config;
}
return config;
}
public CanalConfig getCanalConfigSummary() {
return CanalConfig.find.query()
.setDisableLazyLoading(true)
.select("name, modifiedTime")
.where()
.eq("id", 1L)
.findOne();
}View on GitHub (pinned to 87be50e876)
Solutions
- Provide either a valid clusterId or a non-zero serverId in the request.
- Ensure serverId is not 0 (the code treats serverId != 0 as the active condition).
- Validate the request payload before calling the service method.
- Check the UI form binding actually sends the selected cluster/server id.
Defensive patterns
Strategy: validation
Validate before calling
if ((clusterId == null || clusterId == 0) && (serverId == null || serverId == 0)) {
throw new IllegalArgumentException("Either clusterId or a non-zero serverId must be provided");
} Prevention
- Validate the request has a non-zero clusterId or serverId client-side.
- Treat serverId == 0 as absent (the service does).
- Add UI form validation requiring one identifier.
When it happens
Trigger: Requesting canal config with clusterId null/0 AND serverId null/0 (or serverId == 0). Both branches are skipped and the else throws 'clusterId and serverId are all empty'.
Common situations: UI/API call omitted both identifiers; client sent serverId=0 (treated as empty by the != 0 guard); a malformed request after a cluster+server were both deselected.
Related errors
- empty cluster or server id
- canal.adminUser is empty , pls check https://github.com/alib
- canal.adminPasswd is empty , pls check https://github.com/al
- 节点信息已存在
- ERROR Config: {} {}
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/25eb72bfdc581f36.
Report an issue: GitHub.