iflytek/astron-agent · error · BusinessException
8518
8518
Error message
database.table.field.lack
What it means
Thrown by the private validateParams helper of DatabaseService when a required field (isRequired=true) with no default value is missing from the request params. Code 8518, message 'database.table.field.lack'. It enforces NOT-NULL requiredness at the service layer before DML is built.
Solutions
- Read the log 'Missing required field: <name>' to see which field is missing.
- Add the missing key with a valid value to the params map.
- If the field should be optional, change isRequired=false or set a defaultValue in the table schema.
- For imports, pre-fill required columns in the template/source file.
Example fix
// before
params.put("name", "row1"); // 'owner' is required, omitted
// after
if (fields.stream().anyMatch(f -> Boolean.TRUE.equals(f.getIsRequired()) && f.getDefaultValue() == null && !params.containsKey(f.getName()))) {
throw new IllegalArgumentException("fill required fields before submit");
}
params.put("owner", "alice"); Defensive patterns
Strategy: validation
Validate before calling
for (DbTableField f : fields) {
if (Boolean.TRUE.equals(f.getIsRequired()) && f.getDefaultValue() == null && !params.containsKey(f.getName())) {
throw new IllegalArgumentException("missing required field: " + f.getName());
}
} Try / catch
try {
databaseService.operateTableData(dto);
} catch (BusinessException ex) {
if ("database.table.field.lack".equals(ex.getMessage())) {
log.warn("required field missing; prompt user for missing inputs");
}
throw ex;
} Prevention
- Render required fields as mandatory in client forms
- Re-check schema after table edits; requiredness may have changed
- For imports, pre-fill required columns in templates
When it happens
Trigger: Insert/update operation where params lacks a key for a field marked isRequired=true whose defaultValue is null (and the field is not a system field skipped for insert). E.g. insert omitting a required 'title' column.
Common situations: Client form doesn't render a newly-added required field; bulk import rows with empty cells for required columns; older API clients built before a field became required.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Header mismatch! Expected headers: , Actual headers:
- 8517
- Invalid RID value provided.
- User UID cannot be null
- User ID cannot be null
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a3a39977761bdf10.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:734
}
}
// 3. Validate required fields
for (DbTableField field : fields) {
// Skip system field validation (for insert operations)
if (operateType.equals(DBOperateEnum.INSERT.getCode()) && Arrays.asList(SYSTEM_FIELDS).contains(field.getName())) {
continue;
}
if (operateType.equals(DBOperateEnum.DELETE.getCode()) || operateType.equals(DBOperateEnum.UPDATE.getCode())) {
// For delete and update operations, uuid and create_time are not validated
if (Arrays.asList("uuid", "create_time").contains(field.getName())) {
continue;
}
}
// Validate required fields without default values
if (Boolean.TRUE.equals(field.getIsRequired()) && field.getDefaultValue() == null && !params.containsKey(field.getName())) {
log.error("Missing required field: " + field.getName());
throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_LACK);
}
}
}
private String buildDml(String tableName, Map<String, Object> params, Integer operateType) {
StringBuilder sql = new StringBuilder();
String table = dialect.quoteIdent(tableName);
if (DBOperateEnum.INSERT.getCode().equals(operateType)) {
// Filter null
Map<String, Object> nonNull = params.entrySet()
.stream()
.filter(e -> e.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
List<String> cols = new ArrayList<>();
List<String> vals = new ArrayList<>();
cols.add(dialect.quoteIdent("uid"));View on GitHub (pinned to 5e758547a8)