{"record":{"id":"0493306fbe73d684","repo":"alibaba/canal","slug":"no-clickhouse-adapter-found-for-config-key","errorCode":null,"errorMessage":"No clickhouse adapter found for config key: {}","messagePattern":"No clickhouse adapter found for config key: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/ClickHouseAdapter.java","lineNumber":81,"sourceCode":"        return clickHouseMapping;\n    }\n\n    @Override\n    public void init(OuterAdapterConfig configuration, Properties envProperties) {\n        this.envProperties = envProperties;\n        this.configuration = configuration;\n        // Load DB type from adapter.launch/bootstrap.yml\n        Map<String, String> properties = configuration.getProperties();\n        String dbType = JdbcUtils.getDbType(properties.get(\"jdbc.url\"), null);\n        // 当.yml文件编码格式存在问题，此处clickhouse yml文件构建 可能会抛出异常\n        Map<String, MappingConfig> clickHouseMappingTmp = ConfigLoader.load(envProperties);\n        // 过滤不匹配的key的配置\n        clickHouseMappingTmp.forEach((key, config) -> {\n            addConfig(key, config);\n        });\n\n        if (clickHouseMapping.isEmpty()) {\n            throw new RuntimeException(\"No clickhouse adapter found for config key: \" + configuration.getKey());\n        }\n\n        // 初始化连接池\n        dataSource = new DruidDataSource();\n        dataSource.setDriverClassName(properties.get(\"jdbc.driverClassName\"));\n        dataSource.setUrl(properties.get(\"jdbc.url\"));\n        dataSource.setUsername(properties.get(\"jdbc.username\"));\n        dataSource.setPassword(properties.get(\"jdbc.password\"));\n        dataSource.setInitialSize(1);\n        dataSource.setMinIdle(1);\n        dataSource.setMaxActive(30);\n        dataSource.setMaxWait(60000);\n        dataSource.setTimeBetweenEvictionRunsMillis(60000);\n        dataSource.setMinEvictableIdleTimeMillis(300000);\n        dataSource.setUseUnfairLock(true);\n        dataSource.setDefaultAutoCommit(false); // disable auto commit or disable Transactional\n        dataSource.setDbType(dbType);\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/ClickHouseAdapter.java#L63-L99","documentation":"Thrown by ClickHouseAdapter.init after loading all clickhouse mapping config files and filtering them through addConfig (which checks outerAdapterKey/destination match). If no config file matched this adapter's key, clickHouseMapping is empty and init aborts. This means the adapter was declared in the launcher config but no corresponding *-clickstore.yml mapping file was loaded or matched.","triggerScenarios":"An adapter entry in the launcher YAML whose key has no matching mapping config file under resources/clickhouse/ (or the config dir); the mapping config's outerAdapterKey does not equal the adapter key and is not null-prefix-matched; the mapping file is missing or named so MappingConfigsLoader does not pick it up.","commonSituations":"Misnamed outerAdapterKey in the mapping file vs the adapter key in launcher config; mapping yml file placed outside the scanned path or with wrong suffix; yml encoding/format issue causing YamlUtils to return null; first-time setup forgetting to create the clickhouse mapping file.","solutions":["Create at least one clickhouse mapping config file (e.g. mytable-clickhouse.yml) under the scanned resources/clickhouse directory.","Ensure the mapping file's outerAdapterKey matches the adapter's key in the launcher config, or is null so prefix-matching applies.","Confirm the mapping file name matches the loader's expected pattern (contains the marker 'clickhouse').","Check that the yml parses (correct encoding UTF-8, valid YAML) so ConfigLoader does not silently skip it."],"exampleFix":"# before: launcher declares adapter key 'clickhouse-1' but no mapping file matches\n# after: create resources/clickhouse/mytable-clickhouse.yml with:\ncaseSensitive: true\nouterAdapterKey: clickhouse-1\ndestination: exampleDb\ndbMapping:\n  database: mydb\n  table: mytable\n  targetTable: mytable\n  targetPk:\n    id: id","handlingStrategy":"validation","validationCode":"// Before starting the adapter, assert at least one mapping file resolves to this key.\n// (Run in a bootstrap check; clickHouseMapping is populated by addConfig matching outerAdapterKey.)\n// Verify files exist and keys match:\n// - launcher adapter key: e.g. 'clickhouse-1'\n// - each mapping yml outerAdapterKey must equal 'clickhouse-1' (or be null for prefix match)","typeGuard":null,"tryCatchPattern":"try {\n    clickHouseAdapter.init(config, envProperties);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"No clickhouse adapter found\")) {\n        logger.error(\"No mapping config matched adapter key '{}'. Check outerAdapterKey in yml files.\", config.getKey());\n    }\n    throw e;\n}","preventionTips":["Always create at least one clickhouse mapping yml per adapter instance.","Keep the mapping's outerAdapterKey aligned with the launcher adapter key.","Place mapping files under the scanned resources/clickhouse directory with the expected name marker.","Ensure yml encoding is UTF-8 so ConfigLoader does not silently skip files."],"tags":["clickhouse-adapter","canal-adapter","config","startup","mapping"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}