{"record":{"id":"a6b4ed536a37b758","repo":"alibaba/canal","slug":"unsupport-metamode-for","errorCode":null,"errorMessage":"unsupport MetaMode for {}","messagePattern":"unsupport MetaMode for (.+?)","errorType":"validation","errorClass":"CanalException","httpStatus":null,"severity":"error","filePath":"instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java","lineNumber":157,"sourceCode":"            metaManager = new MemoryMetaManager();\n        } else if (mode.isZookeeper()) {\n            metaManager = new ZooKeeperMetaManager();\n            ((ZooKeeperMetaManager) metaManager).setZkClientx(getZkclientx());\n        } else if (mode.isMixed()) {\n            // metaManager = new MixedMetaManager();\n            metaManager = new PeriodMixedMetaManager();// 换用优化过的mixed, at\n                                                       // 2012-09-11\n            // 设置内嵌的zk metaManager\n            ZooKeeperMetaManager zooKeeperMetaManager = new ZooKeeperMetaManager();\n            zooKeeperMetaManager.setZkClientx(getZkclientx());\n            ((PeriodMixedMetaManager) metaManager).setZooKeeperMetaManager(zooKeeperMetaManager);\n        } else if (mode.isLocalFile()) {\n            FileMixedMetaManager fileMixedMetaManager = new FileMixedMetaManager();\n            fileMixedMetaManager.setDataDir(parameters.getDataDir());\n            fileMixedMetaManager.setPeriod(parameters.getMetaFileFlushPeriod());\n            metaManager = fileMixedMetaManager;\n        } else {\n            throw new CanalException(\"unsupport MetaMode for \" + mode);\n        }\n\n        logger.info(\"init metaManager end! \\n\\t load CanalMetaManager:{} \", metaManager.getClass().getName());\n    }\n\n    protected void initEventStore() {\n        logger.info(\"init eventStore begin...\");\n        StorageMode mode = parameters.getStorageMode();\n        if (mode.isMemory()) {\n            MemoryEventStoreWithBuffer memoryEventStore = new MemoryEventStoreWithBuffer();\n            memoryEventStore.setBufferSize(parameters.getMemoryStorageBufferSize());\n            memoryEventStore.setBufferMemUnit(parameters.getMemoryStorageBufferMemUnit());\n            memoryEventStore.setBatchMode(BatchMode.valueOf(parameters.getStorageBatchMode().name()));\n            memoryEventStore.setDdlIsolation(parameters.getDdlIsolation());\n            memoryEventStore.setRaw(parameters.getMemoryStorageRawEntry());\n            eventStore = memoryEventStore;\n        } else if (mode.isFile()) {\n            // 后续版本支持","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/instance/manager/src/main/java/com/alibaba/otter/canal/instance/manager/CanalInstanceWithManager.java#L139-L175","documentation":"The terminal else-branch in initMetaManager() (CanalInstanceWithManager.java:156-157): thrown when parameters.getMetaMode() is not MEMORY, ZOOKEEPER, MIXED, or LOCAL_FILE. CanalException with text 'unsupport MetaMode for ' + mode. Given the MetaMode enum currently defines exactly those four values and the parameter parser rejects unknown names earlier, this branch is effectively unreachable in shipped code — it exists as a defensive fallback for a future enum value that has no manager wiring yet.","triggerScenarios":"A new MetaMode enum constant is added without a corresponding branch in initMetaManager, or a custom CanalParameter subclass returns a MetaMode object whose is*() methods all return false. With the stock enum and parser, no normal configuration string reaches this line.","commonSituations":"Almost never seen in practice; hypothetically from a fork that adds a MetaMode constant (e.g. REDIS) but forgets to extend initMetaManager, or from reflection/test code injecting a mocked MetaMode. If you see it, suspect a customized canal build rather than a config typo.","solutions":["Confirm you are running stock canal — if on a fork, check whether a new MetaMode was added without an initMetaManager branch and add the branch (or revert the enum).","Verify canal.instance.metaMode is one of MEMORY/ZOOKEEPER/MIXED/LOCAL_FILE; an unknown value normally fails at enum parse before reaching this code, but a malformed custom properties source could bypass it.","If reached via reflection/test, return a MetaMode with one of the recognised is*() flags true."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Defensive: confirm the configured MetaMode is one canal can wire\nCanalParameter.MetaMode mode = parameters.getMetaMode();\nif (!(mode.isMemory() || mode.isZookeeper() || mode.isMixed() || mode.isLocalFile())) {\n    throw new IllegalArgumentException(\"Unsupported canal.instance.metaMode: \" + mode);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict canal.instance.metaMode to MEMORY/ZOOKEEPER/MIXED/LOCAL_FILE.","On a fork that extends MetaMode, add a matching branch in initMetaManager.","For tests using mocked CanalParameter, return MetaMode.MEMORY."],"tags":["configuration","meta-manager","enum","instance-manager","defensive"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}