flipped-aurora/gin-vue-admin · error

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

Error message

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

What it means

Each field requires a non-empty FieldDesc, the human-readable description used in generated comments, front-end labels, and Swagger docs. validateExecutionPlan throws this error when fields[i].fieldDesc is empty. Note FieldName has already been normalized (first letter uppercased) before this check.

Source

Thrown at server/mcp/gva_execute.go:361

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

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

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Add a short fieldDesc describing the field's business meaning
  2. If generating from an existing DB, reuse the column comment as fieldDesc
  3. Re-run gva_execute; iterate since only the first invalid field is reported per run

Example fix

// before
{"fieldName":"Name","fieldDesc":"","fieldType":"string"}
// after
{"fieldName":"Name","fieldDesc":"article name","fieldType":"string"}
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

func hasFieldDesc(f Field) bool { return f.FieldDesc != "" }

Prevention

When it happens

Trigger: A field entry in the execution plan missing fieldDesc or providing ""/null while fieldName is set.

Common situations: Plans where the LLM filled technical fields but skipped the description; batch-generated fields from a table dump with no column comments; users who considered descriptions optional polish.

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/63fb1b06c1969181. Report an issue: GitHub.