flipped-aurora/gin-vue-admin · error

模块 %d 的 fields 不能为空,至少需要一个字段

Error message

模块 %d 的 fields 不能为空,至少需要一个字段

What it means

A module with no field definitions cannot produce a model, so validateExecutionPlan rejects plans where modules[i].fields is an empty array or missing. At least one field entry is required. This check runs in Handle after the module-level string fields pass.

Source

Thrown at server/mcp/gva_execute.go:347

				return fmt.Errorf("模块 %d 的 structName 不能为空", moduleIndex+1)
			}
			if moduleInfo.TableName == "" {
				return fmt.Errorf("模块 %d 的 tableName 不能为空", moduleIndex+1)
			}
			if moduleInfo.Description == "" {
				return fmt.Errorf("模块 %d 的 description 不能为空", moduleIndex+1)
			}
			if moduleInfo.Abbreviation == "" {
				return fmt.Errorf("模块 %d 的 abbreviation 不能为空", moduleIndex+1)
			}
			if moduleInfo.PackageName == "" {
				return fmt.Errorf("模块 %d 的 packageName 不能为空", moduleIndex+1)
			}
			if moduleInfo.HumpPackageName == "" {
				return fmt.Errorf("模块 %d 的 humpPackageName 不能为空", moduleIndex+1)
			}
			if len(moduleInfo.Fields) == 0 {
				return fmt.Errorf("模块 %d 的 fields 不能为空,至少需要一个字段", moduleIndex+1)
			}

			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)
				}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Add at least one field object to modules[i].fields
  2. Start with an ID or primary business field; each field needs fieldName, fieldDesc, fieldType, fieldJson, columnName
  3. Re-run the tool once every module has fields

Example fix

// before
{"packageName":"article","fields":[]}
// after
{"packageName":"article","fields":[{"fieldName":"Name","fieldDesc":"name","fieldType":"string","fieldJson":"name","columnName":"name"}]}
Defensive patterns

Strategy: validation

Validate before calling

for i, m := range plan.Modules {
  if len(m.Fields) == 0 {
    return fmt.Errorf("modules[%d].fields must contain at least one field", i)
  }
}

Type guard

func hasFields(m Module) bool { return len(m.Fields) > 0 }

Prevention

When it happens

Trigger: Submitting an execution plan to gva_execute with modules[i].fields omitted, [], or null.

Common situations: LLM plans that stopped generating mid-module; users scaffolding a stub module intending to add fields later; JSON serialization dropping an empty fields array.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/60848a79bd425f91. Report an issue: GitHub.