{"record":{"id":"b324e1124e5987d8","repo":"flipped-aurora/gin-vue-admin","slug":"needcreatedpackage-true-packageinfo","errorCode":null,"errorMessage":"当 needCreatedPackage=true 时，packageInfo 不能为空","messagePattern":"当 needCreatedPackage=true 时，packageInfo 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":303,"sourceCode":"\t}, nil\n}\n\n// validateExecutionPlan 验证执行计划的完整性\nfunc (g *GVAExecutor) validateExecutionPlan(ctx context.Context, plan *ExecutionPlan) error {\n\tif plan.PackageName == \"\" {\n\t\treturn errors.New(\"packageName 不能为空\")\n\t}\n\tif plan.PackageType != \"package\" && plan.PackageType != \"plugin\" {\n\t\treturn errors.New(\"packageType 必须是 'package' 或 'plugin'\")\n\t}\n\n\tif plan.NeedCreatedPackage && plan.PackageInfo != nil && plan.PackageType != plan.PackageInfo.Template {\n\t\treturn errors.New(\"packageType 和 packageInfo.template 必须保持一致\")\n\t}\n\n\tif plan.NeedCreatedPackage {\n\t\tif plan.PackageInfo == nil {\n\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 不能为空\")","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L285-L321","documentation":"validateExecutionPlan requires that when NeedCreatedPackage is true, the plan must carry a non-nil PackageInfo — the metadata (name, template, label, desc) needed to create the new package/plugin. A nil PackageInfo with NeedCreatedPackage=true means the executor was told to create something but given nothing to create it with.","triggerScenarios":"executionPlan has `needCreatedPackage: true` but the `packageInfo` object is missing entirely (or explicitly null) from the plan JSON.","commonSituations":"Re-executing an old plan where only changes to an existing package were intended, but needCreatedPackage was left true; an LLM emitting the flag without the payload; JSON serialization dropping a null object.","solutions":["Provide a complete packageInfo object alongside needCreatedPackage: true.","If no new package should be created, set needCreatedPackage: false instead of omitting packageInfo.","Ensure packageInfo is a real object, not null, in the serialized arguments.","Validate plan shape client-side before calling the tool (see validationCode)."],"exampleFix":"// before\n{ packageName: \"order-center\", packageType: \"plugin\", needCreatedPackage: true }\n\n// after\n{ packageName: \"order-center\", packageType: \"plugin\", needCreatedPackage: true,\n  packageInfo: { packageName: \"order-center\", template: \"plugin\", label: \"订单中心\", desc: \"订单管理插件\" } }","handlingStrategy":"validation","validationCode":"function requirePackageInfo(plan) {\n  if (plan.needCreatedPackage && (plan.packageInfo == null || typeof plan.packageInfo !== 'object')) {\n    throw new Error('needCreatedPackage=true requires a packageInfo object');\n  }\n  return plan;\n}","typeGuard":"function hasPackageInfoWhenCreating(plan) {\n  return !plan.needCreatedPackage || (plan.packageInfo != null && typeof plan.packageInfo === 'object');\n}","tryCatchPattern":"try {\n  return await callTool('gva_execute', { executionPlan: plan });\n} catch (err) {\n  if (String(err.message).includes('packageInfo 不能为空')) {\n    plan.needCreatedPackage = false; // or fill plan.packageInfo = buildDefaultPackageInfo(plan)\n    return callTool('gva_execute', { executionPlan: plan });\n  }\n  throw err;\n}","preventionTips":["Set needCreatedPackage=false when the plan only modifies existing resources","Always build packageInfo together with the flag via one factory function","Check that your JSON serializer does not drop null/undefined nested objects"],"tags":["mcp","validation","go","null-check"],"backgroundTag":"missing-required-field","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}