{"record":{"id":"da4ebddbd043e247","repo":"flipped-aurora/gin-vue-admin","slug":"needcreatedmodules-true-modulesinfo","errorCode":null,"errorMessage":"当 needCreatedModules=true 时，modulesInfo 不能为空","messagePattern":"当 needCreatedModules=true 时，modulesInfo 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":321,"sourceCode":"\t\t\treturn errors.New(\"当 needCreatedPackage=true 时，packageInfo 不能为空\")\n\t\t}\n\t\tif plan.PackageInfo.PackageName == \"\" {\n\t\t\treturn errors.New(\"packageInfo.packageName 不能为空\")\n\t\t}\n\t\tif plan.PackageInfo.Template != \"package\" && plan.PackageInfo.Template != \"plugin\" {\n\t\t\treturn errors.New(\"packageInfo.template 必须是 'package' 或 'plugin'\")\n\t\t}\n\t\tif plan.PackageInfo.Label == \"\" {\n\t\t\treturn errors.New(\"packageInfo.label 不能为空\")\n\t\t}\n\t\tif plan.PackageInfo.Desc == \"\" {\n\t\t\treturn errors.New(\"packageInfo.desc 不能为空\")\n\t\t}\n\t}\n\n\tif plan.NeedCreatedModules {\n\t\tif len(plan.ModulesInfo) == 0 {\n\t\t\treturn errors.New(\"当 needCreatedModules=true 时，modulesInfo 不能为空\")\n\t\t}\n\n\t\tfor moduleIndex, moduleInfo := range plan.ModulesInfo {\n\t\t\tif moduleInfo.Package == \"\" {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 package 不能为空\", moduleIndex+1)\n\t\t\t}\n\t\t\tif moduleInfo.StructName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 structName 不能为空\", moduleIndex+1)\n\t\t\t}\n\t\t\tif moduleInfo.TableName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 tableName 不能为空\", moduleIndex+1)\n\t\t\t}\n\t\t\tif moduleInfo.Description == \"\" {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 description 不能为空\", moduleIndex+1)\n\t\t\t}\n\t\t\tif moduleInfo.Abbreviation == \"\" {\n\t\t\t\treturn fmt.Errorf(\"模块 %d 的 abbreviation 不能为空\", moduleIndex+1)\n\t\t\t}","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L303-L339","documentation":"When NeedCreatedModules is true, validateExecutionPlan requires ModulesInfo to contain at least one module entry. The executor cannot generate \"modules\" if the list is empty, so the plan is rejected before any module-level validation (each module's package field, etc.) begins.","triggerScenarios":"executionPlan has `needCreatedModules: true` but `modulesInfo` is an empty array or omitted from the plan JSON.","commonSituations":"A plan template with the flag defaulted to true and no modules filled in; an LLM emitting the flag intending module creation later; serialization dropping an empty array; confusion between needCreatedPackage and needCreatedModules flags.","solutions":["Provide at least one entry in modulesInfo, each with a non-empty `package` field.","If no modules should be generated, set needCreatedModules: false instead of leaving an empty list.","Ensure the client actually serializes a non-empty modulesInfo array (empty arrays may be dropped by some serializers).","Validate the flag/list pairing client-side before calling the tool."],"exampleFix":"// before\n{ packageName: \"order-center\", packageType: \"plugin\", needCreatedModules: true }\n\n// after\n{ packageName: \"order-center\", packageType: \"plugin\", needCreatedModules: true,\n  modulesInfo: [\n    { package: \"order\", moduleName: \"order\", label: \"订单\", desc: \"订单管理\" }\n  ] }","handlingStrategy":"validation","validationCode":"function requireModulesWhenFlagged(plan) {\n  if (plan.needCreatedModules && (!Array.isArray(plan.modulesInfo) || plan.modulesInfo.length === 0)) {\n    throw new Error('needCreatedModules=true requires a non-empty modulesInfo array');\n  }\n  return plan;\n}","typeGuard":"function hasModulesWhenFlagged(plan) {\n  return !plan.needCreatedModules || (Array.isArray(plan.modulesInfo) && plan.modulesInfo.length > 0 && plan.modulesInfo.every(m => typeof m?.package === 'string' && m.package.length > 0));\n}","tryCatchPattern":"try {\n  return await callTool('gva_execute', { executionPlan: plan });\n} catch (err) {\n  if (String(err.message).includes('modulesInfo 不能为空')) {\n    plan.needCreatedModules = false; // or plan.modulesInfo = buildDefaultModules(plan)\n    return callTool('gva_execute', { executionPlan: plan });\n  }\n  throw err;\n}","preventionTips":["Only set needCreatedModules=true when at least one module entry is ready","Verify your JSON serializer emits empty arrays (some omit them)","Build modulesInfo and the flag together via one factory so they stay in sync"],"tags":["mcp","validation","go","execution-plan"],"backgroundTag":"missing-required-field","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}