{"record":{"id":"8c4d6c14d6d0926a","repo":"flipped-aurora/gin-vue-admin","slug":"v-executionplan","errorCode":null,"errorMessage":"解析执行计划失败: %v\n\n请确保ExecutionPlan格式正确，参考工具描述中的结构体格式要求","messagePattern":"解析执行计划失败: (.+?)\n\n请确保ExecutionPlan格式正确，参考工具描述中的结构体格式要求","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_execute.go","lineNumber":230,"sourceCode":"}\n\n// Handle 处理执行请求（移除确认步骤）\nfunc (g *GVAExecutor) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n\texecutionPlanData, ok := request.GetArguments()[\"executionPlan\"]\n\tif !ok {\n\t\treturn nil, errors.New(\"参数错误：executionPlan 必须提供\")\n\t}\n\n\t// 解析执行计划\n\tplanJSON, err := json.Marshal(executionPlanData)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"解析执行计划失败: %v\", err)\n\t}\n\n\tvar plan ExecutionPlan\n\terr = json.Unmarshal(planJSON, &plan)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"解析执行计划失败: %v\\n\\n请确保ExecutionPlan格式正确，参考工具描述中的结构体格式要求\", err)\n\t}\n\n\t// 验证执行计划的完整性\n\tif err := g.validateExecutionPlan(ctx, &plan); err != nil {\n\t\treturn nil, fmt.Errorf(\"执行计划验证失败: %v\", err)\n\t}\n\n\t// 获取原始需求（可选）\n\tvar originalRequirement string\n\tif reqData, ok := request.GetArguments()[\"requirement\"]; ok {\n\t\tif reqStr, ok := reqData.(string); ok {\n\t\t\toriginalRequirement = reqStr\n\t\t}\n\t}\n\n\t// 直接执行创建操作（无确认步骤）\n\tresult := g.executeCreation(ctx, &plan)\n","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_execute.go#L212-L248","documentation":"gva_execute's Handle (server/mcp/gva_execute.go:230) fails when the executionPlan object cannot be unmarshaled into the ExecutionPlan struct — the JSON exists but its shape/types don't match the struct fields. The message explicitly tells the caller to follow the ExecutionPlan format in the tool description. This is the most common caller-side contract error for this tool.","triggerScenarios":"Calling gva_execute where a field has the wrong JSON type (e.g. needCreatedModules: \"true\" string instead of boolean, modulesInfo: object instead of array, packageInfo: array instead of object) or fields that cannot bind to request.AutoCode / SysAutoCodePackageCreate.","commonSituations":"LLM clients generating the plan with wrong types (booleans quoted, arrays as single objects); version drift where the struct gained/renamed fields; clients copying an outdated example payload.","solutions":["Read the %v suffix — encoding/json reports the exact field path and type mismatch (e.g. \"json: cannot unmarshal string into Go struct field ...needCreatedModules of type bool\").","Fix that field's type: booleans unquoted, modulesInfo/dictionariesInfo as arrays, packageInfo as object.","Compare the payload against the schema in the tool's New() description (gva_execute tool definition).","Remove unknown/wrongly-typed extra fields; keep only fields from the documented schema.","Re-run gva_analyze first to base the plan on the current package/dictionary snapshot."],"exampleFix":"// before\n{\"executionPlan\": {\"packageName\":\"user\", \"needCreatedModules\":\"true\", \"modulesInfo\": {\"structName\":\"User\"}}}\n// after: correct types — boolean flag, array for modulesInfo\n{\"executionPlan\": {\"packageName\":\"user\", \"packageType\":\"package\", \"needCreatedModules\":true, \"modulesInfo\":[{\"package\":\"user\",\"structName\":\"User\",\"tableName\":\"users\",\"description\":\"用户管理\",\"abbreviation\":\"u\",\"packageName\":\"user\",\"humpPackageName\":\"user\",\"fields\":[{\"fieldName\":\"UserName\",\"fieldDesc\":\"用户名\",\"fieldType\":\"string\",\"fieldJson\":\"userName\",\"columnName\":\"user_name\"}]}]}}","handlingStrategy":"validation","validationCode":"function validatePlanTypes(plan) {\n  if (typeof plan.needCreatedPackage !== 'boolean') return 'needCreatedPackage must be boolean'\n  if (typeof plan.needCreatedModules !== 'boolean') return 'needCreatedModules must be boolean'\n  if (typeof plan.needCreatedDictionaries !== 'boolean') return 'needCreatedDictionaries must be boolean'\n  if (plan.modulesInfo != null && !Array.isArray(plan.modulesInfo)) return 'modulesInfo must be an array'\n  if (plan.packageInfo != null && (typeof plan.packageInfo !== 'object' || Array.isArray(plan.packageInfo))) return 'packageInfo must be an object'\n  if (!['package', 'plugin'].includes(plan.packageType)) return 'packageType must be package|plugin'\n  return null\n}","typeGuard":"function isWellTypedPlan(v) {\n  return typeof v === 'object' && v !== null &&\n    typeof v.packageName === 'string' &&\n    ['package', 'plugin'].includes(v.packageType) &&\n    typeof v.needCreatedModules === 'boolean' &&\n    (v.modulesInfo === undefined || Array.isArray(v.modulesInfo))\n}","tryCatchPattern":"try {\n  return await callTool('gva_execute', { executionPlan: plan })\n} catch (e) {\n  if (String(e.message).includes('请确保ExecutionPlan格式正确')) {\n    // parse the json field-path in e.message and fix that field's type, then retry once\n  }\n  throw e\n}","preventionTips":["Quote types strictly: booleans unquoted, arrays as [...], objects as {...}.","Regenerate payloads from the current tool schema after GVA upgrades.","Test plans against a dev instance before production runs."],"tags":["mcp","json","schema-validation","type-mismatch","go"],"backgroundTag":"json-unmarshal-type-mismatch","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}