iflytek/astron-agent · error · BusinessException
DATABASE_IMPORT_FAILED
DATABASE_IMPORT_FAILED
Error message
importTableData partial failures: {} What it means
DatabaseService.importTableData imports rows from an uploaded file into a database table. When some rows fail (summary.failed > 0) it builds a diagnostic message with up to 10 failed-row samples, logs it as a warning, and throws BusinessException(DATABASE_IMPORT_FAILED). Any other exception during import is caught, logged, and also converted to DATABASE_IMPORT_FAILED.
Solutions
- Read the logged '导入部分失败' summary with failed-row samples (index + message) and fix those specific rows in the source file.
- Validate the file's columns against the current table schema (types, NOT NULL, lengths) before re-uploading.
- Check date/number formats in the file match the table column expectations and locale.
- Verify the file encoding (UTF-8 vs GBK) matches what the parser expects to avoid corrupted values.
- If the whole import fails (log line 'import data failed'), check the full exception for SQL/connection errors and database permissions.
Example fix
// before
// CSV cell: created_at = "2026/9/12" while column expects 'yyyy-MM-dd HH:mm:ss'
// after
// normalize dates in the file or during row conversion
LocalDateTime dt = LocalDate.parse(raw, DateTimeFormatter.ofPattern("yyyy/M/d")).atStartOfDay(); Defensive patterns
Strategy: validation
Validate before calling
// validate the file rows against the table schema before import
rows.forEach((row, i) => {
schema.columns.forEach((c) => {
const v = row[c.name];
if (c.notNull && (v == null || v === '')) throw new Error(`Row ${i}: ${c.name} is required`);
if (v != null && c.type === 'number' && isNaN(Number(v))) throw new Error(`Row ${i}: ${c.name} must be numeric`);
});
}); Try / catch
try {
await dbService.importTableData(tbId, file);
} catch (e) {
if (e.code === 'DATABASE_IMPORT_FAILED') {
// server log 'importTableData partial failures' lists failing row indexes/messages
console.error('Import failed: fix flagged rows in the source file, then re-upload');
} else throw e;
} Prevention
- Dry-run validation of each row against the current table schema before writing.
- Normalize dates/numbers/encodings (UTF-8) in the upload pipeline.
- Re-validate files against the schema after any table DDL change.
- Import in batches with per-row error capture rather than failing the whole batch silently.
When it happens
Trigger: Batch insert where one or more rows violate the target schema: type mismatch, constraint/PK violation, null in NOT NULL column, value out of range, string too long, or an SQL error mid-import (connection loss, permission denied).
Common situations: Excel/CSV upload with malformed cells (text in numeric columns, wrong date formats); file encoding mismatch causing garbage values; table schema changed after the file was exported; importing into the wrong database type (MySQL vs PostgreSQL dialect differences).
Related errors
- WORKFLOW_IMPORT_FAILED
- CREATE_BOT_FAILED
- UPDATE_BOT_FAILED
- NOTIFICATION_MARK_READ_FAILED
- NOTIFICATION_DELETE_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/19d4c760ecd22ade.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:945
sql,
UserInfoManagerHandler.getUserId(),
SpaceInfoUtil.getSpaceId(),
dbInfo.getDbId(),
DBOperateEnum.INSERT.getCode(),
execDev);
});
// 3) Summary
if (!summary.errors.isEmpty()) {
// Record the first 10 failed examples
StringBuilder sb = new StringBuilder();
sb.append("导入部分失败:success=")
.append(summary.success)
.append(", failed=")
.append(summary.failed)
.append(". 失败样例:");
summary.errors.stream().limit(10).forEach(err -> sb.append("\n#").append(err.index).append(" : ").append(err.message));
log.warn("importTableData partial failures: {}", sb);
throw new BusinessException(ResponseEnum.DATABASE_IMPORT_FAILED);
}
} catch (Exception ex) {
log.error("import data failed, tbId={}, execDev={}, fileName={}", tbId, execDev, file.getOriginalFilename(), ex);
throw new BusinessException(ResponseEnum.DATABASE_IMPORT_FAILED);
}
}
@Transactional
public void copyTable(Long tbId) {
try {
DbTable dbTable = dbTableMapper.selectById(tbId);
// Unify and standardize the copy names, and avoid illegal characters
String tableName = NamePolicy.copyName(dbTable.getName());
// build DDL CREATE TABLE new AS SELECT * FROM old
DbTableDto dbTableDto = new DbTableDto();
dbTableDto.setName(tableName);View on GitHub (pinned to 5e758547a8)