iflytek/astron-agent · error · BusinessException

8528

8528

Error message

database.table.export.failed

What it means

Thrown by DatabaseService.exportData when EasyExcel fails to write the table export workbook to the HTTP response output stream. The method wraps any exception from the EasyExcel write pipeline (head building, sheet creation, doWrite) into BusinessException(ResponseEnum.DATABASE_TABLE_EXPORT_FAILED, code 8528). It indicates the Excel export for a database table could not be delivered to the client.

Solutions

  1. Check the server log line 'export data failed, params:{...}' for the root exception (often an IOException from the servlet output stream).
  2. Verify the export response has not already been committed and content-type/content-disposition headers are set before EasyExcel writes.
  3. Confirm dataList cell values match the headList schema and contain EasyExcel-compatible types (or add converters).
  4. For large tables, paginate or stream in batches to avoid OOM during doWrite.

Example fix

// before
EasyExcel.write(response.getOutputStream())
    .head(headList)
    .sheet("data")
    .doWrite(dataList);
// after
response.reset();
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
try (ServletOutputStream out = response.getOutputStream()) {
    EasyExcel.write(out)
        .head(headList)
        .sheet("data")
        .doWrite(() -> batchIterator); // stream batches instead of one huge list
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before export
if (dataList == null || headList == null || response.isCommitted()) {
    throw new IllegalArgumentException("export requires headList/dataList and an uncommitted response");
}

Type guard

boolean isExportable(List<?> headList, List<?> dataList) {
    return headList != null && !headList.isEmpty() && dataList != null;
}

Try / catch

try {
    EasyExcel.write(response.getOutputStream()).head(headList).sheet("data").doWrite(dataList);
} catch (Exception ex) {
    log.error("export data failed, params:{}", dto, ex);
    throw new BusinessException(ResponseEnum.DATABASE_TABLE_EXPORT_FAILED);
}

Prevention

When it happens

Trigger: Calling the table-data export endpoint when EasyExcel.write(...).head(headList).sheet("data").doWrite(dataList) throws — e.g. headList/dataList structure mismatch, IOException on response.getOutputStream() (client disconnected, response already committed), or a cell value type EasyExcel cannot serialize.

Common situations: Large exports that exceed memory or hit client-side connection timeouts mid-stream; response already partially written/committed before the call; incompatible data types in dataList columns; custom head list not matching data rows.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/a5e21a32664033c2. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:1081

                    } else {
                        line.add(val != null ? val : "");
                    }
                }
                dataList.add(line);
            }

            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.setCharacterEncoding("utf-8");
            String fileName = URLEncoder.encode(dbTable.getName(), "UTF-8").replaceAll("\\+", "%20");
            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");

            EasyExcel.write(response.getOutputStream())
                    .head(headList)
                    .sheet("data")
                    .doWrite(dataList);
        } catch (Exception ex) {
            log.error("export data failed, params:{}", dto, ex);
            throw new BusinessException(ResponseEnum.DATABASE_TABLE_EXPORT_FAILED);
        }
    }

    public List<DbTableInfoVo> getDbTableInfoList() {
        List<DbTableInfoVo> result = new ArrayList<>();
        dbInfoMapper.selectList(new QueryWrapper<DbInfo>().lambda()
                .and(SpaceInfoUtil.getSpaceId() == null,
                        wrapper -> wrapper.eq(DbInfo::getUid, UserInfoManagerHandler.getUserId())
                                .isNull(DbInfo::getSpaceId))
                .eq(SpaceInfoUtil.getSpaceId() != null, DbInfo::getSpaceId, SpaceInfoUtil.getSpaceId())
                .eq(DbInfo::getDeleted, false))
                .forEach(dbInfo -> {
                    DbTableInfoVo dbTableInfoVo = new DbTableInfoVo();
                    dbTableInfoVo.setLabel(dbInfo.getName());
                    dbTableInfoVo.setValue(dbInfo.getDbId().toString());
                    List<DbTable> dbTables = dbTableMapper.selectList(new QueryWrapper<DbTable>().lambda()
                            .eq(DbTable::getDbId, dbInfo.getId())
                            .eq(DbTable::getDeleted, false));

View on GitHub (pinned to 5e758547a8)