{"record":{"id":"222358ac4e81b42b","repo":"iflytek/astron-agent","slug":"8531-database-too-many-export-ids","errorCode":"8531","errorMessage":"database.too.many.export.ids","messagePattern":"database\\.too\\.many\\.export\\.ids","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java","lineNumber":1013,"sourceCode":"            dbTableFieldMapper.insertBatch(copyTableFields);\n        } catch (Exception ex) {\n            log.error(\"copy table failed, tbId={}\", tbId, ex);\n            throw new BusinessException(ResponseEnum.DATABASE_TABLE_COPY_FAILED);\n        }\n    }\n\n    public void exportTableData(DatabaseExportDto dto, HttpServletResponse response) {\n        dataPermissionCheckTool.checkTbBelong(dto.getTbId());\n        try {\n            DbTable dbTable = dbTableMapper.selectById(dto.getTbId());\n            DbInfo dbInfo = dbInfoMapper.selectById(dbTable.getDbId());\n\n            String table = dialect.quoteIdent(dbTable.getName());\n            String dml = \"SELECT * FROM \" + table + \" LIMIT 1000 OFFSET 0\";\n\n            if (dto.getDataIds() != null && !dto.getDataIds().isEmpty()) {\n                if (dto.getDataIds().size() > MAX_EXPORT_IDS) {\n                    throw new BusinessException(ResponseEnum.DATABASE_TOO_MANY_EXPORT_IDS);\n                }\n                // All perform digital whitelist verification\n                List<Long> ids = dto.getDataIds()\n                        .stream()\n                        .map(x -> SqlRenderer.requireLong(x, \"id\"))\n                        .collect(Collectors.toList());\n                String in = ids.stream().map(String::valueOf).collect(Collectors.joining(\",\"));\n                dml = \"SELECT * FROM \" + table + \" WHERE \" + dialect.quoteIdent(\"id\") + \" IN (\" + in + \")\";\n            }\n            SqlRenderer.denyMultiStmtOrComment(dml);\n\n            List<JSONObject> data = (List<JSONObject>) coreSystemService.execDML(\n                    dml,\n                    UserInfoManagerHandler.getUserId(),\n                    SpaceInfoUtil.getSpaceId(),\n                    dbInfo.getDbId(),\n                    DBOperateEnum.SELECT.getCode(),\n                    dto.getExecDev());","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L995-L1031","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndto.setDataIds(allRowIds); // 50,000 ids\nexportService.exportTableData(dto, response);\n// after\nif (allRowIds.size() > 1000) {\n    dto.setDataIds(null); // full-table export path\n} else {\n    dto.setDataIds(allRowIds);\n}\nexportService.exportTableData(dto, response);","handlingStrategy":"validation","validationCode":"if (dataIds != null && dataIds.size() > 1000) {\n    throw new IllegalArgumentException(\"too many ids for selective export; use full export instead\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    exportService.exportTableData(dto, response);\n} catch (BusinessException ex) {\n    if (\"database.too.many.export.ids\".equals(ex.getMessage())) {\n        dto.setDataIds(null); // fall back to full-table export\n        exportService.exportTableData(dto, response);\n    } else { throw ex; }\n}","preventionTips":["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"],"tags":["export","limit","validation"],"backgroundTag":"payload-too-large","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}