flipped-aurora/gin-vue-admin · error

模块 %d 字段 %d 的 fieldName 不能为空

Error message

模块 %d 字段 %d 的 fieldName 不能为空

What it means

Every field inside modules[i].fields must have a non-empty FieldName, the Go struct field name. validateExecutionPlan throws this error for fields[i].fieldName being "". Immediately after this check the validator auto-capitalizes a lowercase first character, so passing a lowercase name is tolerated.

Source

Thrown at server/mcp/gva_execute.go:352

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

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Set fieldName to a non-empty exported Go identifier (e.g. "Name"); a lowercase first letter is auto-uppercased
  2. Check every field object in the module, not just the first failing one (validation stops at the first error)
  3. Re-run gva_execute after fixing

Example fix

// before
{"fieldName":"","fieldJson":"name"}
// after
{"fieldName":"Name","fieldJson":"name"}
Defensive patterns

Strategy: validation

Validate before calling

for i, m := range plan.Modules {
  for j, f := range m.Fields {
    if f.FieldName == "" {
      return fmt.Errorf("modules[%d].fields[%d].fieldName is required", i, j)
    }
  }
}

Type guard

func hasFieldName(f Field) bool { return f.FieldName != "" }

Prevention

When it happens

Trigger: A plan field entry lacking fieldName, or setting it to ""/null, e.g. when a model hallucinated a field object with only fieldJson or fieldType.

Common situations: Partial field objects from truncated LLM output; users writing json tag-style lowercase names and leaving fieldName blank by mistake; copy-paste errors when editing plan JSON.

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


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