flipped-aurora/gin-vue-admin · error

packageType 和 packageInfo.template 必须保持一致

Error message

packageType 和 packageInfo.template 必须保持一致

What it means

When the plan requests package creation (NeedCreatedPackage=true) and packageInfo is present, validateExecutionPlan requires plan.PackageType to equal plan.PackageInfo.Template. This cross-field consistency check prevents a mismatch where the top-level type says one thing and the creation template another, which would make the generator produce the wrong artifact.

Source

Thrown at server/mcp/gva_execute.go:298

	return &mcp.CallToolResult{
		Content: []mcp.Content{
			mcp.NewTextContent(fmt.Sprintf("执行结果:\n\n%s%s", string(responseJSON), reviewMessage)),
		},
	}, nil
}

// validateExecutionPlan 验证执行计划的完整性
func (g *GVAExecutor) validateExecutionPlan(ctx context.Context, plan *ExecutionPlan) error {
	if plan.PackageName == "" {
		return errors.New("packageName 不能为空")
	}
	if plan.PackageType != "package" && plan.PackageType != "plugin" {
		return errors.New("packageType 必须是 'package' 或 'plugin'")
	}

	if plan.NeedCreatedPackage && plan.PackageInfo != nil && plan.PackageType != plan.PackageInfo.Template {
		return errors.New("packageType 和 packageInfo.template 必须保持一致")
	}

	if plan.NeedCreatedPackage {
		if plan.PackageInfo == nil {
			return errors.New("当 needCreatedPackage=true 时,packageInfo 不能为空")
		}
		if plan.PackageInfo.PackageName == "" {
			return errors.New("packageInfo.packageName 不能为空")
		}
		if plan.PackageInfo.Template != "package" && plan.PackageInfo.Template != "plugin" {
			return errors.New("packageInfo.template 必须是 'package' 或 'plugin'")
		}
		if plan.PackageInfo.Label == "" {
			return errors.New("packageInfo.label 不能为空")
		}
		if plan.PackageInfo.Desc == "" {
			return errors.New("packageInfo.desc 不能为空")
		}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Make packageInfo.template equal the top-level packageType (or remove the redundant field and derive one from the other).
  2. Search the call site for where packageType and template are set and update them together.
  3. Add a client-side consistency check before invoking the tool.
  4. If the template should follow the type, set template: packageType when building the plan.

Example fix

// before
{ packageName: "order-center", packageType: "plugin", needCreatedPackage: true,
  packageInfo: { packageName: "order-center", template: "package", label: "订单中心", desc: "..." } }

// after
{ packageName: "order-center", packageType: "plugin", needCreatedPackage: true,
  packageInfo: { packageName: "order-center", template: "plugin", label: "订单中心", desc: "..." } }
Defensive patterns

Strategy: validation

Validate before calling

function ensureTypeConsistency(plan) {
  if (plan.needCreatedPackage && plan.packageInfo && plan.packageInfo.template !== plan.packageType) {
    throw new Error(`packageType (${plan.packageType}) must equal packageInfo.template (${plan.packageInfo.template})`);
  }
  return plan;
}

Type guard

function planTypesMatch(plan) {
  return !plan.needCreatedPackage || plan.packageInfo == null || plan.packageInfo.template === plan.packageType;
}

Try / catch

try {
  return await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
  if (String(err.message).includes('必须保持一致')) {
    plan.packageInfo.template = plan.packageType; // sync nested template to top-level type
    return callTool('gva_execute', { executionPlan: plan });
  }
  throw err;
}

Prevention

When it happens

Trigger: executionPlan with needCreatedPackage=true, packageInfo provided, and packageType="plugin" while packageInfo.template="package" (or vice versa).

Common situations: The plan was copied from a different tool call and only one of the two fields was updated; an LLM generated the two fields independently; a UI form let the user change packageType without syncing the nested template.

Related errors


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