{"record":{"id":"a63189d3838c06b3","repo":"alibaba/canal","slug":"dbmapping-database","errorCode":null,"errorMessage":"dbMapping.database","messagePattern":"dbMapping\\.database","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/config/MappingConfig.java","lineNumber":86,"sourceCode":"    public void setDbMapping(DbMapping dbMapping) {\n        this.dbMapping = dbMapping;\n    }\n\n    public String getDestination() {\n        return destination;\n    }\n\n    public void setDestination(String destination) {\n        this.destination = destination;\n    }\n\n    public AdapterMapping getMapping() {\n        return dbMapping;\n    }\n\n    public void validate() {\n        if (dbMapping.database == null || dbMapping.database.isEmpty()) {\n            throw new NullPointerException(\"dbMapping.database\");\n        }\n        if (!dbMapping.getMirrorDb() && (dbMapping.table == null || dbMapping.table.isEmpty())) {\n            throw new NullPointerException(\"dbMapping.table\");\n        }\n        if (!dbMapping.getMirrorDb() && (dbMapping.targetTable == null || dbMapping.targetTable.isEmpty())) {\n            throw new NullPointerException(\"dbMapping.targetTable\");\n        }\n    }\n\n    public static class DbMapping implements AdapterMapping {\n\n        private boolean             mirrorDb        = false;                 // 是否镜像库\n        private String              database;                                // 数据库名或schema名\n        private String              table;                                   // 表名\n        private Map<String, String> targetPk        = new LinkedHashMap<>(); // 目标表主键字段\n        private boolean             mapAll          = false;                 // 映射所有字段\n        private String              targetDb;                                // 目标库名\n        private String              targetTable;                             // 目标表名","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/config/MappingConfig.java#L68-L104","documentation":"Thrown as NullPointerException by MappingConfig.validate when dbMapping.database is null or empty. database (the source database/schema name) is the one universally required field for every clickhouse mapping, mirrorDb or not. ConfigLoader catches it and re-throws as 'ERROR Config: <file> dbMapping.database'.","triggerScenarios":"A mapping yml with a dbMapping block that omits the database key; database set to an empty string; YAML indentation placing database outside the dbMapping map so it binds null.","commonSituations":"Template config with database left as a placeholder; indentation error nesting database under the wrong key; renamed field during a config refactor.","solutions":["Add a non-empty database value under dbMapping in the named yml file.","Verify YAML indentation so database is a child of dbMapping.","Cross-check against a known-good mapping file in the repo.","Restart the adapter to reload."],"exampleFix":"# before:\ndbMapping:\n  table: orders\n  targetTable: orders\n# after:\ndbMapping:\n  database: shop\n  table: orders\n  targetTable: orders","handlingStrategy":"validation","validationCode":"// Pre-flight check before adapter init.\nMappingConfig.DbMapping m = config.getDbMapping();\nif (m == null || m.getDatabase() == null || m.getDatabase().isEmpty()) {\n    throw new IllegalArgumentException(\"dbMapping.database is required (file: \" + fileName + \")\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set dbMapping.database in every clickhouse mapping file.","Check YAML indentation so database sits under dbMapping.","Lint configs in CI to catch missing required fields before deploy."],"tags":["clickhouse-adapter","canal-adapter","config","validation","null-pointer"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}