{"record":{"id":"3dd350c8fbef009d","repo":"alibaba/nacos","slug":"102","errorCode":"102","errorMessage":"dataSource or tableName is null","messagePattern":"dataSource or tableName is null","errorType":"error_code","errorClass":"NacosRuntimeException","httpStatus":null,"severity":"error","filePath":"plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/MapperManager.java","lineNumber":109,"sourceCode":"        Map<String, Mapper> mapperMap =\n            MAPPER_SPI_MAP.computeIfAbsent(mapper.getDataSource(), key -> new HashMap<>(16));\n        mapperMap.putIfAbsent(mapper.getTableName(), mapper);\n    }\n    \n    /**\n     * Get the mapper by table name.\n     *\n     * @param tableName  table name.\n     * @param dataSource the datasource.\n     * @return mapper.\n     */\n    public <R extends Mapper> R findMapper(String dataSource, String tableName) {\n        if (LOGGER.isDebugEnabled()) {\n            LOGGER.debug(\"[MapperManager] findMapper dataSource: {}, tableName: {}\", dataSource,\n                tableName);\n        }\n        if (StringUtils.isBlank(dataSource) || StringUtils.isBlank(tableName)) {\n            throw new NacosRuntimeException(FIND_DATASOURCE_ERROR_CODE,\n                \"dataSource or tableName is null\");\n        }\n        Map<String, Mapper> tableMapper = MAPPER_SPI_MAP.get(dataSource);\n        if (Objects.isNull(tableMapper)) {\n            throw new NacosRuntimeException(FIND_DATASOURCE_ERROR_CODE,\n                \"[MapperManager] Failed to find the datasource,dataSource:\" + dataSource);\n        }\n        Mapper mapper = tableMapper.get(tableName);\n        if (Objects.isNull(mapper)) {\n            throw new NacosRuntimeException(FIND_TABLE_ERROR_CODE,\n                \"[MapperManager] Failed to find the table ,tableName:\" + tableName);\n        }\n        if (dataSourceLogEnable) {\n            return MapperProxy.createSingleProxy(mapper);\n        }\n        return (R) mapper;\n    }\n    ","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/MapperManager.java#L91-L127","documentation":"Thrown by MapperManager.findMapper as NacosRuntimeException with code FIND_DATASOURCE_ERROR_CODE (102) when the dataSource or tableName argument is blank. This is the input-validation branch before any SPI map lookup occurs.","triggerScenarios":"Calling findMapper(dataSource, tableName) where either argument is null, empty, or whitespace. Reached by any server component resolving a SQL Mapper for a given datasource+table pair.","commonSituations":"A caller passing a null dataSource because the persistence type was not resolved from config; a null tableName due to a missing table constant; misconfigured datasource plugin returning blank identifiers.","solutions":["Resolve and pass a non-blank dataSource (e.g. ' derby', 'mysql', 'postgresql') and a non-blank tableName.","Trace upstream: ensure the datasource type is determined from nacos.persistence.type or plugin config before findMapper is called.","Add a guard at the caller to fail with a clearer message before reaching MapperManager."],"exampleFix":"// before\nMapper m = mapperManager.findMapper(null, \"config_info\"); // null datasource -> 102\n\n// after\nString ds = EnvUtil.getProperty(\"nacos.persistence.type\", \"derby\");\nMapper m = mapperManager.findMapper(ds, \"config_info\");","handlingStrategy":"validation","validationCode":"if (StringUtils.isBlank(dataSource) || StringUtils.isBlank(tableName)) {\n    throw new IllegalArgumentException(\"dataSource and tableName are required\");\n}\nmapperManager.findMapper(dataSource, tableName);","typeGuard":"static boolean validMapperArgs(String ds, String table) {\n    return StringUtils.isNotBlank(ds) && StringUtils.isNotBlank(table);\n}","tryCatchPattern":null,"preventionTips":["Resolve the datasource type from config before calling findMapper.","Pass non-blank table constants, never null.","Fail fast at the caller with a clearer message."],"tags":["plugin","datasource","mapper","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}