{"record":{"id":"4e90c3331fd7bfe3","repo":"flipped-aurora/gin-vue-admin","slug":"d-d-columnname","errorCode":null,"errorMessage":"模块 %d 字段 %d 的 columnName 不能为空","messagePattern":"模块 (.+?) 字段 (.+?) 的 columnName 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":370,"sourceCode":"\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldName 不能为空\", moduleIndex+1, i+1)\n\t\t\t\t}\n\t\t\t\tif len(field.FieldName) > 0 {\n\t\t\t\t\tfirstChar := string(field.FieldName[0])\n\t\t\t\t\tif firstChar >= \"a\" && firstChar <= \"z\" {\n\t\t\t\t\t\tmoduleInfo.Fields[i].FieldName = strings.ToUpper(firstChar) + field.FieldName[1:]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif field.FieldDesc == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldDesc 不能为空\", moduleIndex+1, i+1)\n\t\t\t\t}\n\t\t\t\tif field.FieldType == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldType 不能为空\", moduleIndex+1, i+1)\n\t\t\t\t}\n\t\t\t\tif field.FieldJson == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldJson 不能为空\", moduleIndex+1, i+1)\n\t\t\t\t}\n\t\t\t\tif field.ColumnName == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 columnName 不能为空\", moduleIndex+1, i+1)\n\t\t\t\t}\n\n\t\t\t\tvalidFieldTypes := []string{\"string\", \"int\", \"int64\", \"float64\", \"bool\", \"time.Time\", \"enum\", \"picture\", \"video\", \"file\", \"pictures\", \"array\", \"richtext\", \"json\"}\n\t\t\t\tif !slices.Contains(validFieldTypes, field.FieldType) {\n\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldType '%s' 不支持\", moduleIndex+1, i+1, field.FieldType)\n\t\t\t\t}\n\n\t\t\t\tif field.FieldSearchType != \"\" {\n\t\t\t\t\tvalidSearchTypes := []string{\"=\", \"!=\", \">\", \">=\", \"<\", \"<=\", \"LIKE\", \"BETWEEN\", \"NOT BETWEEN\", \"IN\", \"NOT IN\"}\n\t\t\t\t\tif !slices.Contains(validSearchTypes, field.FieldSearchType) {\n\t\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 fieldSearchType '%s' 不支持\", moduleIndex+1, i+1, field.FieldSearchType)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif field.DataSource != nil {\n\t\t\t\t\tassociationValue := field.DataSource.Association\n\t\t\t\t\tif associationValue == 2 && field.FieldType != \"array\" {\n\t\t\t\t\t\tlogger.WithCtx(ctx).Mod(\"mcp\").Info(fmt.Sprintf(\"module %d field %d association=2, force fieldType to array\", moduleIndex+1, i+1))","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L352-L388","documentation":"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.","triggerScenarios":"Calling the MCP gva_execute tool (via Handle) with a plan whose modules[n].fields[m] has FieldJson/FieldType set but ColumnName empty.","commonSituations":"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.","solutions":["Set ColumnName on the offending field to a snake_case DB column name (e.g. fieldJson 'userName' -> 'user_name')","Verify the execution plan JSON matches the required field schema (fieldJson, fieldType, columnName all required)","Regenerate the plan ensuring the prompt instructs the model to always emit columnName"],"exampleFix":"// before\n{\"fieldJson\":\"userName\",\"fieldType\":\"string\"}\n// after\n{\"fieldJson\":\"userName\",\"fieldType\":\"string\",\"columnName\":\"user_name\"}","handlingStrategy":"validation","validationCode":"func validPlanFields(modules []Module) error {\n  for mi, m := range modules {\n    for fi, f := range m.Fields {\n      if f.ColumnName == \"\" {\n        return fmt.Errorf(\"module %d field %d missing columnName\", mi+1, fi+1)\n      }\n    }\n  }\n  return nil\n}","typeGuard":"func hasColumnName(f Field) bool { return f.ColumnName != \"\" }","tryCatchPattern":null,"preventionTips":["Always include columnName in generated field objects","snake_case the fieldJson as the default columnName","Validate the plan JSON against a schema with columnName required before calling the tool"],"tags":["validation","code-generator","mcp"],"backgroundTag":"missing-required-field","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}