{"record":{"id":"c3229de036d5bd47","repo":"flipped-aurora/gin-vue-admin","slug":"packagename","errorCode":null,"errorMessage":"packageName 不能为空","messagePattern":"packageName 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":291,"sourceCode":"\t\tNextActions:    result.NextActions,\n\t}\n\n\tresponseJSON, err := json.MarshalIndent(response, \"\", \"  \")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"序列化结果失败: %v\", err)\n\t}\n\n\treturn &mcp.CallToolResult{\n\t\tContent: []mcp.Content{\n\t\t\tmcp.NewTextContent(fmt.Sprintf(\"执行结果：\\n\\n%s%s\", string(responseJSON), reviewMessage)),\n\t\t},\n\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'\")","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L273-L309","documentation":"validateExecutionPlan checks the decoded ExecutionPlan struct before execution proceeds. The first check requires plan.PackageName to be a non-empty string, since the executor must know which package/plugin resource to generate. An empty PackageName means the plan is unidentifiable and the executor refuses to run.","triggerScenarios":"Calling the gva_execute tool with executionPlan present but its `packageName` field empty (\"\") or omitted, then Handle unmarshals the plan and invokes validateExecutionPlan.","commonSituations":"An LLM agent generated a plan skeleton and left packageName blank; a template filled in with an empty variable; the field was named `package_name` in the payload so Go unmarshaling left PackageName at its zero value.","solutions":["Set `packageName` to the target package/plugin's name in the executionPlan object.","Confirm the JSON field name is `packageName` (matches the struct tag) so it binds to ExecutionPlan.PackageName.","Validate the plan client-side before calling the tool (see validationCode).","If the name comes from user input, trim whitespace and re-check non-empty before sending."],"exampleFix":"// before\nconst plan = { packageType: \"plugin\", needCreatedPackage: true }\n\n// after\nconst plan = { packageName: \"order-center\", packageType: \"plugin\", needCreatedPackage: true }","handlingStrategy":"validation","validationCode":"function requirePackageName(plan) {\n  if (!plan || typeof plan.packageName !== 'string' || plan.packageName.trim() === '') {\n    throw new Error('executionPlan.packageName is required and must be non-empty');\n  }\n  return plan;\n}\n// call: requirePackageName(plan) before invoking gva_execute","typeGuard":"function hasPackageName(plan) {\n  return typeof plan?.packageName === 'string' && plan.packageName.trim().length > 0;\n}","tryCatchPattern":"try {\n  const result = await callTool('gva_execute', { executionPlan: plan });\n} catch (err) {\n  if (String(err.message).includes('packageName 不能为空')) {\n    plan.packageName = plan.packageName?.trim() || deriveNameFromLabel(plan);\n    return callTool('gva_execute', { executionPlan: plan });\n  }\n  throw err;\n}","preventionTips":["Validate the plan against its JSON schema client-side before every tool call","Trim and check user-supplied names before placing them into the plan","Use consistent camelCase keys matching the Go struct tags"],"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"}