{"record":{"id":"e05a554667880317","repo":"flipped-aurora/gin-vue-admin","slug":"d-d-fieldtype","errorCode":null,"errorMessage":"模块 %d 字段 %d 的 fieldType 不能为空","messagePattern":"模块 (.+?) 字段 (.+?) 的 fieldType 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":364,"sourceCode":"\t\t\tif len(moduleInfo.Fields) == 0 {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 fields 不能为空，至少需要一个字段\", moduleIndex+1)\n\t\t\t}\n\n\t\t\tfor i, field := range moduleInfo.Fields {\n\t\t\t\tif field.FieldName == \"\" {\n\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}","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L346-L382","documentation":"Each field must declare a FieldType drawn from the generator's supported Go types (string, int, int64, float64, bool, time.Time, enum, picture, video, file, pictures, array, richtext, json). validateExecutionPlan throws this error when fields[i].fieldType is empty; an unsupported non-empty value triggers a different error.","triggerScenarios":"A plan field entry missing fieldType or setting it to \"\"/null. Commonly the field object only carried fieldName/fieldDesc/fieldJson.","commonSituations":"Plans generated from DB schemas where the SQL-to-Go type mapping step was skipped; users writing SQL types like varchar or bigint directly instead of the supported Go-side type names.","solutions":["Set fieldType to one of the supported values: string, int, int64, float64, bool, time.Time, enum, picture, video, file, pictures, array, richtext, json","Map SQL types: varchar->string, bigint->int64, timestamp->time.Time, etc.","Re-run gva_execute"],"exampleFix":"// before\n{\"fieldName\":\"Name\",\"fieldDesc\":\"name\",\"fieldType\":\"\"}\n// after\n{\"fieldName\":\"Name\",\"fieldDesc\":\"name\",\"fieldType\":\"string\"}","handlingStrategy":"validation","validationCode":"var validTypes = map[string]bool{\"string\":true,\"int\":true,\"int64\":true,\"float64\":true,\"bool\":true,\"time.Time\":true,\"enum\":true,\"picture\":true,\"video\":true,\"file\":true,\"pictures\":true,\"array\":true,\"richtext\":true,\"json\":true}\nfor i, m := range plan.Modules {\n  for j, f := range m.Fields {\n    if !validTypes[f.FieldType] {\n      return fmt.Errorf(\"modules[%d].fields[%d].fieldType invalid: %q\", i, j, f.FieldType)\n    }\n  }\n}","typeGuard":"func hasValidFieldType(f Field) bool {\n  switch f.FieldType {\n  case \"string\",\"int\",\"int64\",\"float64\",\"bool\",\"time.Time\",\"enum\",\"picture\",\"video\",\"file\",\"pictures\",\"array\",\"richtext\",\"json\":\n    return true\n  }\n  return false\n}","tryCatchPattern":null,"preventionTips":["Map SQL column types to supported Go-side types before writing the plan","Never leave fieldType empty or use raw SQL type names like varchar","Keep the supported-type list handy when authoring plans by hand"],"tags":["mcp","code-generation","validation","type-mapping"],"backgroundTag":"missing-required-field","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}