{"record":{"id":"6394b448ce8fe7d0","repo":"flipped-aurora/gin-vue-admin","slug":"d-d-fieldtype-s","errorCode":null,"errorMessage":"模块 %d 字段 %d 的 fieldType '%s' 不支持","messagePattern":"模块 (.+?) 字段 (.+?) 的 fieldType '(.+?)' 不支持","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":375,"sourceCode":"\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))\n\t\t\t\t\t\tmoduleInfo.Fields[i].FieldType = \"array\"\n\t\t\t\t\t}\n\t\t\t\t\tif associationValue != 1 && associationValue != 2 {\n\t\t\t\t\t\treturn fmt.Errorf(\"模块 %d 字段 %d 的 dataSource.association 必须是 1 或 2\", moduleIndex+1, i+1)\n\t\t\t\t\t}","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L357-L393","documentation":"validateExecutionPlan restricts fieldType to a fixed whitelist of supported Go/JSON types (string, int, int64, float64, bool, time.Time, enum, picture, video, file, pictures, array, richtext, json). Any other value is rejected because the code generator has no template mapping for it.","triggerScenarios":"Calling the gva_execute tool with a plan whose fields[m].fieldType is not in the whitelist (e.g. 'int32', 'float', 'String', 'datetime', 'text').","commonSituations":"Case mismatch ('String' vs 'string'); using SQL types ('varchar','datetime') instead of Go types; new field types added to the generator UI but not to the MCP validator's whitelist (or vice versa).","solutions":["Change fieldType to one of the whitelisted values closest to the intent (e.g. 'datetime' -> 'time.Time', 'text' -> 'richtext')","Fix casing to match the whitelist exactly (lowercase 'string', 'bool')","Check the validFieldTypes slice in server/mcp/gva_execute.go and the generator's supported types before authoring a plan"],"exampleFix":"// before\n{\"fieldJson\":\"createdAt\",\"fieldType\":\"datetime\",\"columnName\":\"created_at\"}\n// after\n{\"fieldJson\":\"createdAt\",\"fieldType\":\"time.Time\",\"columnName\":\"created_at\"}","handlingStrategy":"validation","validationCode":"var validFieldTypes = []string{\"string\",\"int\",\"int64\",\"float64\",\"bool\",\"time.Time\",\"enum\",\"picture\",\"video\",\"file\",\"pictures\",\"array\",\"richtext\",\"json\"}\nif !slices.Contains(validFieldTypes, f.FieldType) { return fmt.Errorf(\"bad fieldType %q\", f.FieldType) }","typeGuard":"func isSupportedFieldType(t string) bool {\n  return slices.Contains([]string{\"string\",\"int\",\"int64\",\"float64\",\"bool\",\"time.Time\",\"enum\",\"picture\",\"video\",\"file\",\"pictures\",\"array\",\"richtext\",\"json\"}, t)\n}","tryCatchPattern":null,"preventionTips":["Keep a shared constant list of allowed types instead of free-form strings","Normalize casing before submission","Map SQL-ish type names (datetime, text) to supported Go types in your generator"],"tags":["validation","code-generator","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}