alibaba/nacos · error · NacosRuntimeException
102
102
Error message
dataSource or tableName is null
What it means
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.
Source
Thrown at plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/MapperManager.java:109
Map<String, Mapper> mapperMap =
MAPPER_SPI_MAP.computeIfAbsent(mapper.getDataSource(), key -> new HashMap<>(16));
mapperMap.putIfAbsent(mapper.getTableName(), mapper);
}
/**
* Get the mapper by table name.
*
* @param tableName table name.
* @param dataSource the datasource.
* @return mapper.
*/
public <R extends Mapper> R findMapper(String dataSource, String tableName) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("[MapperManager] findMapper dataSource: {}, tableName: {}", dataSource,
tableName);
}
if (StringUtils.isBlank(dataSource) || StringUtils.isBlank(tableName)) {
throw new NacosRuntimeException(FIND_DATASOURCE_ERROR_CODE,
"dataSource or tableName is null");
}
Map<String, Mapper> tableMapper = MAPPER_SPI_MAP.get(dataSource);
if (Objects.isNull(tableMapper)) {
throw new NacosRuntimeException(FIND_DATASOURCE_ERROR_CODE,
"[MapperManager] Failed to find the datasource,dataSource:" + dataSource);
}
Mapper mapper = tableMapper.get(tableName);
if (Objects.isNull(mapper)) {
throw new NacosRuntimeException(FIND_TABLE_ERROR_CODE,
"[MapperManager] Failed to find the table ,tableName:" + tableName);
}
if (dataSourceLogEnable) {
return MapperProxy.createSingleProxy(mapper);
}
return (R) mapper;
}
View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before
Mapper m = mapperManager.findMapper(null, "config_info"); // null datasource -> 102
// after
String ds = EnvUtil.getProperty("nacos.persistence.type", "derby");
Mapper m = mapperManager.findMapper(ds, "config_info"); Defensive patterns
Strategy: validation
Validate before calling
if (StringUtils.isBlank(dataSource) || StringUtils.isBlank(tableName)) {
throw new IllegalArgumentException("dataSource and tableName are required");
}
mapperManager.findMapper(dataSource, tableName); Type guard
static boolean validMapperArgs(String ds, String table) {
return StringUtils.isNotBlank(ds) && StringUtils.isNotBlank(table);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 103
- baseType must not be null
- subtype must not be null
- typeName must not be empty
- PARAMETER_VALIDATE_ERROR
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/3dd350c8fbef009d.
Report an issue: GitHub.