flipped-aurora/gin-vue-admin · error

解析执行计划失败: %v 请确保ExecutionPlan格式正确,参考工具描述中的结构体格式要求

Error message

解析执行计划失败: %v

请确保ExecutionPlan格式正确,参考工具描述中的结构体格式要求

What it means

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.

Source

Thrown at server/mcp/gva_execute.go:230

}

// Handle 处理执行请求(移除确认步骤)
func (g *GVAExecutor) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
	executionPlanData, ok := request.GetArguments()["executionPlan"]
	if !ok {
		return nil, errors.New("参数错误:executionPlan 必须提供")
	}

	// 解析执行计划
	planJSON, err := json.Marshal(executionPlanData)
	if err != nil {
		return nil, fmt.Errorf("解析执行计划失败: %v", err)
	}

	var plan ExecutionPlan
	err = json.Unmarshal(planJSON, &plan)
	if err != nil {
		return nil, fmt.Errorf("解析执行计划失败: %v\n\n请确保ExecutionPlan格式正确,参考工具描述中的结构体格式要求", err)
	}

	// 验证执行计划的完整性
	if err := g.validateExecutionPlan(ctx, &plan); err != nil {
		return nil, fmt.Errorf("执行计划验证失败: %v", err)
	}

	// 获取原始需求(可选)
	var originalRequirement string
	if reqData, ok := request.GetArguments()["requirement"]; ok {
		if reqStr, ok := reqData.(string); ok {
			originalRequirement = reqStr
		}
	}

	// 直接执行创建操作(无确认步骤)
	result := g.executeCreation(ctx, &plan)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. 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").
  2. Fix that field's type: booleans unquoted, modulesInfo/dictionariesInfo as arrays, packageInfo as object.
  3. Compare the payload against the schema in the tool's New() description (gva_execute tool definition).
  4. Remove unknown/wrongly-typed extra fields; keep only fields from the documented schema.
  5. Re-run gva_analyze first to base the plan on the current package/dictionary snapshot.

Example fix

// before
{"executionPlan": {"packageName":"user", "needCreatedModules":"true", "modulesInfo": {"structName":"User"}}}
// after: correct types — boolean flag, array for modulesInfo
{"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"}]}]}}
Defensive patterns

Strategy: validation

Validate before calling

function validatePlanTypes(plan) {
  if (typeof plan.needCreatedPackage !== 'boolean') return 'needCreatedPackage must be boolean'
  if (typeof plan.needCreatedModules !== 'boolean') return 'needCreatedModules must be boolean'
  if (typeof plan.needCreatedDictionaries !== 'boolean') return 'needCreatedDictionaries must be boolean'
  if (plan.modulesInfo != null && !Array.isArray(plan.modulesInfo)) return 'modulesInfo must be an array'
  if (plan.packageInfo != null && (typeof plan.packageInfo !== 'object' || Array.isArray(plan.packageInfo))) return 'packageInfo must be an object'
  if (!['package', 'plugin'].includes(plan.packageType)) return 'packageType must be package|plugin'
  return null
}

Type guard

function isWellTypedPlan(v) {
  return typeof v === 'object' && v !== null &&
    typeof v.packageName === 'string' &&
    ['package', 'plugin'].includes(v.packageType) &&
    typeof v.needCreatedModules === 'boolean' &&
    (v.modulesInfo === undefined || Array.isArray(v.modulesInfo))
}

Try / catch

try {
  return await callTool('gva_execute', { executionPlan: plan })
} catch (e) {
  if (String(e.message).includes('请确保ExecutionPlan格式正确')) {
    // parse the json field-path in e.message and fix that field's type, then retry once
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/8c4d6c14d6d0926a. Report an issue: GitHub.