iflytek/astron-agent · error · BusinessException
8531
8531
Error message
database.too.many.export.ids
What it means
Thrown by DatabaseService.exportTableData when the export request includes more than MAX_EXPORT_IDS data ids. Code 8531, message 'database.too.many.export.ids'. It is a guard preventing unbounded IN-clause queries when exporting selected rows.
Solutions
- Reduce the number of ids per export request below MAX_EXPORT_IDS and paginate the export.
- If the intent is 'export everything', omit dataIds entirely so the default LIMIT 1000 full-table query path is used.
- Change the UI to switch from id-selection to filter-based export when selection exceeds the cap.
- If the business truly needs larger exports, raise MAX_EXPORT_IDS deliberately, understanding SQL IN-clause limits.
Example fix
// before
dto.setDataIds(allRowIds); // 50,000 ids
exportService.exportTableData(dto, response);
// after
if (allRowIds.size() > 1000) {
dto.setDataIds(null); // full-table export path
} else {
dto.setDataIds(allRowIds);
}
exportService.exportTableData(dto, response); Defensive patterns
Strategy: validation
Validate before calling
if (dataIds != null && dataIds.size() > 1000) {
throw new IllegalArgumentException("too many ids for selective export; use full export instead");
} Try / catch
try {
exportService.exportTableData(dto, response);
} catch (BusinessException ex) {
if ("database.too.many.export.ids".equals(ex.getMessage())) {
dto.setDataIds(null); // fall back to full-table export
exportService.exportTableData(dto, response);
} else { throw ex; }
} Prevention
- Cap UI selection exports below the MAX_EXPORT_IDS limit
- Switch to full-table/filter export when 'select all' is used
- Paginate large exports client-side
When it happens
Trigger: Calling the export endpoint with dto.dataIds whose size exceeds MAX_EXPORT_IDS; the explicit size check fires before id whitelist validation and SQL rendering.
Common situations: UI 'select all' sending every row id instead of switching to full-table export mode; users exporting very large saved selections; batch scripts passing thousands of ids.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/222358ac4e81b42b.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:1013
dbTableFieldMapper.insertBatch(copyTableFields);
} catch (Exception ex) {
log.error("copy table failed, tbId={}", tbId, ex);
throw new BusinessException(ResponseEnum.DATABASE_TABLE_COPY_FAILED);
}
}
public void exportTableData(DatabaseExportDto dto, HttpServletResponse response) {
dataPermissionCheckTool.checkTbBelong(dto.getTbId());
try {
DbTable dbTable = dbTableMapper.selectById(dto.getTbId());
DbInfo dbInfo = dbInfoMapper.selectById(dbTable.getDbId());
String table = dialect.quoteIdent(dbTable.getName());
String dml = "SELECT * FROM " + table + " LIMIT 1000 OFFSET 0";
if (dto.getDataIds() != null && !dto.getDataIds().isEmpty()) {
if (dto.getDataIds().size() > MAX_EXPORT_IDS) {
throw new BusinessException(ResponseEnum.DATABASE_TOO_MANY_EXPORT_IDS);
}
// All perform digital whitelist verification
List<Long> ids = dto.getDataIds()
.stream()
.map(x -> SqlRenderer.requireLong(x, "id"))
.collect(Collectors.toList());
String in = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
dml = "SELECT * FROM " + table + " WHERE " + dialect.quoteIdent("id") + " IN (" + in + ")";
}
SqlRenderer.denyMultiStmtOrComment(dml);
List<JSONObject> data = (List<JSONObject>) coreSystemService.execDML(
dml,
UserInfoManagerHandler.getUserId(),
SpaceInfoUtil.getSpaceId(),
dbInfo.getDbId(),
DBOperateEnum.SELECT.getCode(),
dto.getExecDev());View on GitHub (pinned to 5e758547a8)