flipped-aurora/gin-vue-admin · error
模块 %d 字段 %d 的 fieldJson 不能为空
Error message
模块 %d 字段 %d 的 fieldJson 不能为空
What it means
Each field requires a non-empty FieldJson, the JSON tag name used by generated structs for serialization and by the front-end for request/response payloads. validateExecutionPlan throws this error when fields[i].fieldJson is empty. Right after it, ColumnName is checked similarly.
Source
Thrown at server/mcp/gva_execute.go:367
for i, field := range moduleInfo.Fields {
if field.FieldName == "" {
return fmt.Errorf("模块 %d 字段 %d 的 fieldName 不能为空", moduleIndex+1, i+1)
}
if len(field.FieldName) > 0 {
firstChar := string(field.FieldName[0])
if firstChar >= "a" && firstChar <= "z" {
moduleInfo.Fields[i].FieldName = strings.ToUpper(firstChar) + field.FieldName[1:]
}
}
if field.FieldDesc == "" {
return fmt.Errorf("模块 %d 字段 %d 的 fieldDesc 不能为空", moduleIndex+1, i+1)
}
if field.FieldType == "" {
return fmt.Errorf("模块 %d 字段 %d 的 fieldType 不能为空", moduleIndex+1, i+1)
}
if field.FieldJson == "" {
return fmt.Errorf("模块 %d 字段 %d 的 fieldJson 不能为空", moduleIndex+1, i+1)
}
if field.ColumnName == "" {
return fmt.Errorf("模块 %d 字段 %d 的 columnName 不能为空", moduleIndex+1, i+1)
}
validFieldTypes := []string{"string", "int", "int64", "float64", "bool", "time.Time", "enum", "picture", "video", "file", "pictures", "array", "richtext", "json"}
if !slices.Contains(validFieldTypes, field.FieldType) {
return fmt.Errorf("模块 %d 字段 %d 的 fieldType '%s' 不支持", moduleIndex+1, i+1, field.FieldType)
}
if field.FieldSearchType != "" {
validSearchTypes := []string{"=", "!=", ">", ">=", "<", "<=", "LIKE", "BETWEEN", "NOT BETWEEN", "IN", "NOT IN"}
if !slices.Contains(validSearchTypes, field.FieldSearchType) {
return fmt.Errorf("模块 %d 字段 %d 的 fieldSearchType '%s' 不支持", moduleIndex+1, i+1, field.FieldSearchType)
}
}
if field.DataSource != nil {View on GitHub (pinned to 3136500ef3)
Solutions
- Set fieldJson to a camelCase JSON key matching the field (e.g. "createTime" for FieldName "CreateTime")
- Keep it consistent with ColumnName (usually snake_case of the same word) for clean DB/JSON mapping
- Re-run gva_execute
Example fix
// before
{"fieldName":"CreateTime","fieldType":"time.Time","fieldJson":""}
// after
{"fieldName":"CreateTime","fieldType":"time.Time","fieldJson":"createTime"} Defensive patterns
Strategy: validation
Validate before calling
for i, m := range plan.Modules {
for j, f := range m.Fields {
if f.FieldJson == "" {
return fmt.Errorf("modules[%d].fields[%d].fieldJson is required", i, j)
}
}
} Type guard
func hasFieldJson(f Field) bool { return f.FieldJson != "" } Prevention
- Derive fieldJson as the camelCase form of fieldName instead of writing it separately
- Keep fieldJson and columnName in sync (camelCase vs snake_case of the same word)
- Run one pre-flight validator covering fieldName, fieldDesc, fieldType, fieldJson, and columnName per field
When it happens
Trigger: A plan field entry missing fieldJson or providing ""/null while fieldName, fieldDesc, and fieldType are filled.
Common situations: Users who assumed the JSON tag is derived from fieldName automatically; LLM plans that only emitted Go-side names; hand-edited plans where fieldJson was deleted during cleanup.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- 模块 %d 的 tableName 不能为空
- 模块 %d 的 description 不能为空
- 模块 %d 的 abbreviation 不能为空
- 模块 %d 的 packageName 不能为空
- 模块 %d 的 humpPackageName 不能为空
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/ac5155a6b0cd2211.
Report an issue: GitHub.