iflytek/astron-agent · error · BusinessException
DATABASE_ID_CANNOT_EMPTY
DATABASE_ID_CANNOT_EMPTY
Error message
DATABASE_ID_CANNOT_EMPTY
What it means
Thrown by DatabaseService.getDbTableList when the dbId parameter is null. Listing tables for a database requires an explicit database id; without it the service cannot scope the query (and would fail the data-permission check).
Solutions
- Always pass a valid dbId when requesting the table list
- In the UI, require database selection before rendering the table list
- Check that the client variable holding dbId is populated before the request
Example fix
// before
getDbTableList(null)
// after
if (dbId == null) { selectDatabaseFirst(); }
getDbTableList(dbId); Defensive patterns
Strategy: validation
Validate before calling
if (dbId == null) {
throw new IllegalArgumentException("dbId is required to list tables");
} Try / catch
try {
databaseService.getDbTableList(dbId);
} catch (BusinessException e) {
if ("DATABASE_ID_CANNOT_EMPTY".equals(e.getCode())) { /* redirect user to select a database */ }
throw e;
} Prevention
- Always require database selection before fetching its tables
- Mark dbId as required in the API contract/OpenAPI schema
- Guard client code against undefined/null database ids
When it happens
Trigger: Calling the table-list endpoint without the dbId query/path parameter, or invoking getDbTableList(null) directly; frontend calls with an unselected database.
Common situations: Frontend navigates to table list before choosing a database; API client omits the dbId parameter; a variable holding the selected DB id is undefined/null.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/079c965f83478ce2.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:347
// Save to core system
String ddl = buildDDL(dbTableDto, DBOperateEnum.INSERT.getCode(), null);
// Call core system to create table
for (String stmt : safeSplitStatements(ddl)) {
SqlRenderer.denyMultiStmtOrComment(stmt); // At this point each statement does not contain semicolon
coreSystemService.execDDL(stmt, UserInfoManagerHandler.getUserId(), SpaceInfoUtil.getSpaceId(), dbInfo.getDbId());
}
} catch (Exception ex) {
log.error("Failed to create table, params={}", dbTableDto, ex);
throw new BusinessException(ResponseEnum.DATABASE_TABLE_CREATE_FAILED);
}
}
public List<DbTableVo> getDbTableList(Long dbId) {
try {
if (dbId == null) {
throw new BusinessException(ResponseEnum.DATABASE_ID_CANNOT_EMPTY);
}
dataPermissionCheckTool.checkDbBelong(dbId);
List<DbTable> dbTables = dbTableMapper.selectList(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getDbId, dbId)
.orderByDesc(DbTable::getCreateTime)
.eq(DbTable::getDeleted, false));
List<DbTableVo> dbTableVos = new ArrayList<>();
dbTables.forEach(dbTable -> {
DbTableVo dbTableVo = new DbTableVo();
BeanUtils.copyProperties(dbTable, dbTableVo);
dbTableVos.add(dbTableVo);
});
return dbTableVos;
} catch (Exception ex) {
log.error("Failed to get table list, dbId={}", dbId, ex);
throw new BusinessException(ResponseEnum.DATABASE_TABLE_QUERY_LIST_FAILED);
}
}View on GitHub (pinned to 5e758547a8)