{"record":{"id":"ac5155a6b0cd2211","repo":"flipped-aurora/gin-vue-admin","slug":"d-d-fieldjson","errorCode":null,"errorMessage":"模块 %d 字段 %d 的 fieldJson 不能为空","messagePattern":"模块 (.+?) 字段 (.+?) 的 fieldJson 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":367,"sourceCode":"\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}\n\t\t\t\t}\n\n\t\t\t\tif field.DataSource != nil {","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L349-L385","documentation":"Each field requires a non-empty FieldJson, the JSON tag name used by generated structs for serialization and by the front-end for request/response payloads. validateExecutionPlan throws this error when fields[i].fieldJson is empty. Right after it, ColumnName is checked similarly.","triggerScenarios":"A plan field entry missing fieldJson or providing \"\"/null while fieldName, fieldDesc, and fieldType are filled.","commonSituations":"Users who assumed the JSON tag is derived from fieldName automatically; LLM plans that only emitted Go-side names; hand-edited plans where fieldJson was deleted during cleanup.","solutions":["Set fieldJson to a camelCase JSON key matching the field (e.g. \"createTime\" for FieldName \"CreateTime\")","Keep it consistent with ColumnName (usually snake_case of the same word) for clean DB/JSON mapping","Re-run gva_execute"],"exampleFix":"// before\n{\"fieldName\":\"CreateTime\",\"fieldType\":\"time.Time\",\"fieldJson\":\"\"}\n// after\n{\"fieldName\":\"CreateTime\",\"fieldType\":\"time.Time\",\"fieldJson\":\"createTime\"}","handlingStrategy":"validation","validationCode":"for i, m := range plan.Modules {\n  for j, f := range m.Fields {\n    if f.FieldJson == \"\" {\n      return fmt.Errorf(\"modules[%d].fields[%d].fieldJson is required\", i, j)\n    }\n  }\n}","typeGuard":"func hasFieldJson(f Field) bool { return f.FieldJson != \"\" }","tryCatchPattern":null,"preventionTips":["Derive fieldJson as the camelCase form of fieldName instead of writing it separately","Keep fieldJson and columnName in sync (camelCase vs snake_case of the same word)","Run one pre-flight validator covering fieldName, fieldDesc, fieldType, fieldJson, and columnName per field"],"tags":["mcp","code-generation","validation","json-tags"],"backgroundTag":"missing-required-field","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}