alibaba/canal · error · UnsupportedOperationException
unknow mode : for monitor
Error message
unknow mode : for monitor
What it means
Thrown when building an instance-config monitor for a mode that is neither SPRING nor MANAGER. The computing map checks mode.isSpring() then mode.isManager(); the InstanceMode enum only defines SPRING and MANAGER, so this default branch is effectively unreachable for a well-formed config. Hitting it indicates the mode value was constructed by reflection/deserialization from an unknown token, or the enum was extended without updating this branch.
Source
Thrown at deployer/src/main/java/com/alibaba/otter/canal/deployer/CanalController.java:341
rootDir = "../conf";
}
if (StringUtils.equals("otter-canal", System.getProperty("appName"))) {
monitor.setRootConf(rootDir);
} else {
// eclipse debug模式
monitor.setRootConf("src/main/resources/");
}
return monitor;
} else if (mode.isManager()) {
ManagerInstanceConfigMonitor monitor = new ManagerInstanceConfigMonitor();
monitor.setScanIntervalInSecond(scanInterval);
monitor.setDefaultAction(defaultAction);
String managerAddress = getProperty(properties, CanalConstants.CANAL_ADMIN_MANAGER);
monitor.setConfigClient(getManagerClient(managerAddress));
return monitor;
} else {
throw new UnsupportedOperationException("unknow mode :" + mode + " for monitor");
}
});
}
}
private InstanceConfig initGlobalConfig(Properties properties) {
String adminManagerAddress = getProperty(properties, CanalConstants.CANAL_ADMIN_MANAGER);
InstanceConfig globalConfig = new InstanceConfig();
String modeStr = getProperty(properties, CanalConstants.getInstanceModeKey(CanalConstants.GLOBAL_NAME));
if (StringUtils.isNotEmpty(adminManagerAddress)) {
// 如果指定了manager地址,则强制适用manager
globalConfig.setMode(InstanceMode.MANAGER);
} else if (StringUtils.isNotEmpty(modeStr)) {
globalConfig.setMode(InstanceMode.valueOf(StringUtils.upperCase(modeStr)));
}
String lazyStr = getProperty(properties, CanalConstants.getInstancLazyKey(CanalConstants.GLOBAL_NAME));
if (StringUtils.isNotEmpty(lazyStr)) {View on GitHub (pinned to 87be50e876)
Solutions
- Set canal.instance.global.mode to spring or manager (the only supported values).
- Check the InstanceMode enum in your Canal build for newly added values and update if on a custom fork.
- Look upstream in the logs for the actual mode-resolution failure (valueOf) if this appears unreachable.
Defensive patterns
Strategy: validation
Validate before calling
String modeStr = properties.getProperty(CanalConstants.getInstanceModeKey(CanalConstants.GLOBAL_NAME));
if (!"spring".equalsIgnoreCase(modeStr) && !"manager".equalsIgnoreCase(modeStr)) {
throw new IllegalArgumentException("canal.instance.global.mode must be 'spring' or 'manager', got: " + modeStr);
} Prevention
- Set canal.instance.global.mode to spring or manager only.
- Validate the mode string early in deploy scripts.
When it happens
Trigger: canal.instance.global.mode (or per-instance mode) resolves to an InstanceMode other than SPRING/MANAGER. Only possible if a future enum value is added or an invalid string is coerced into the enum via valueOf-like reflection that throws instead — so in practice this branch is defensive dead code.
Common situations: A typo in the mode property usually fails earlier at InstanceMode.valueOf with a different exception; this branch guards a hypothetical future enum value.
Related errors
- unknown mode :
- canal.user = , but canal.passwd is empty , pls check https:
- can't find destination:
- invalid destinations expr
- canal.admin.passwd is empty , pls check https://github.com/a
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/4577845e63c5cb9f.
Report an issue: GitHub.