flipped-aurora/gin-vue-admin · error

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

Error message

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

What it means

validateExecutionPlan checks every field of every module in an MCP-generated auto-create execution plan. This error is thrown when a field entry omits columnName, the database column name required to generate the model and table DDL. Without it the code generator cannot map the field to a physical column.

Source

Thrown at server/mcp/gva_execute.go:370

					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 {
					associationValue := field.DataSource.Association
					if associationValue == 2 && field.FieldType != "array" {
						logger.WithCtx(ctx).Mod("mcp").Info(fmt.Sprintf("module %d field %d association=2, force fieldType to array", moduleIndex+1, i+1))

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Set ColumnName on the offending field to a snake_case DB column name (e.g. fieldJson 'userName' -> 'user_name')
  2. Verify the execution plan JSON matches the required field schema (fieldJson, fieldType, columnName all required)
  3. Regenerate the plan ensuring the prompt instructs the model to always emit columnName

Example fix

// before
{"fieldJson":"userName","fieldType":"string"}
// after
{"fieldJson":"userName","fieldType":"string","columnName":"user_name"}
Defensive patterns

Strategy: validation

Validate before calling

func validPlanFields(modules []Module) error {
  for mi, m := range modules {
    for fi, f := range m.Fields {
      if f.ColumnName == "" {
        return fmt.Errorf("module %d field %d missing columnName", mi+1, fi+1)
      }
    }
  }
  return nil
}

Type guard

func hasColumnName(f Field) bool { return f.ColumnName != "" }

Prevention

When it happens

Trigger: Calling the MCP gva_execute tool (via Handle) with a plan whose modules[n].fields[m] has FieldJson/FieldType set but ColumnName empty.

Common situations: LLM-generated plans omit columnName because the prompt or schema marks it optional; hand-written plans copy a field object with only name and type filled; JSON schema drift after adding the columnName requirement.

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/4e90c3331fd7bfe3. Report an issue: GitHub.