{"record":{"id":"4b0862994436cbe4","repo":"alibaba/canal","slug":"dbmapping-targettable-4b0862","errorCode":null,"errorMessage":"dbMapping.targetTable","messagePattern":"dbMapping\\.targetTable","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/config/MappingConfig.java","lineNumber":90,"sourceCode":"    }\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;                             // 目标表名\n        private Map<String, String> targetColumns;                           // 目标表字段映射\n\n        private boolean             caseInsensitive = false;                 // 目标表不区分大小写，默认是否\n\n        private String              etlCondition;                            // etl条件sql\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/config/MappingConfig.java#L72-L108","documentation":"Thrown by rdb MappingConfig.validate() when dbMapping.targetTable is null or empty AND mirrorDb is false. targetTable is the destination table where data is written; for non-mirror mappings it is mandatory, but mirrorDb mappings derive targets from the schema and omit it, hence the getMirrorDb() guard.","triggerScenarios":"A non-mirror rdb mapping yml's dbMapping block omits or blanks 'targetTable:', or mirrorDb is false/unset on a config meant to be a mirror.","commonSituations":"A table-mapping template had 'targetTable:' deleted. A mirror-schema config forgot 'mirrorDb: true' so the validator still demands a targetTable.","solutions":["For a table mapping, add a non-empty 'targetTable:' under dbMapping (e.g. 'mytest2.user').","If this is a whole-schema mirror, set 'mirrorDb: true' under dbMapping so targetTable/table are not required."],"exampleFix":"# table mapping fix\n# before\ndbMapping:\n  database: mytest\n  table: user\n# after\ndbMapping:\n  database: mytest\n  table: user\n  targetTable: mytest2.user\n# mirror-db alternative\ndbMapping:\n  mirrorDb: true\n  database: mytest","handlingStrategy":"validation","validationCode":"DbMapping m = config.getDbMapping();\nboolean needsTarget = m == null || !m.getMirrorDb();\nif (needsTarget && (m.getTargetTable() == null || m.getTargetTable().isEmpty())) {\n    throw new IllegalArgumentException(\n        \"rdb yml missing dbMapping.targetTable for \" + fileName\n        + \" (or set mirrorDb:true for whole-schema sync)\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For table mappings always set targetTable; for whole-schema mirrors set mirrorDb:true instead.","Validate the mirrorDb/targetTable combination in CI."],"tags":["rdb","config-validation","canal","yaml","mirror-db"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}