flipped-aurora/gin-vue-admin · error

当 needCreatedPackage=true 时,packageInfo 不能为空

Error message

当 needCreatedPackage=true 时,packageInfo 不能为空

What it means

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.

Source

Thrown at server/mcp/gva_execute.go:303

	}, 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 不能为空")
		}
	}

	if plan.NeedCreatedModules {
		if len(plan.ModulesInfo) == 0 {
			return errors.New("当 needCreatedModules=true 时,modulesInfo 不能为空")

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Provide a complete packageInfo object alongside needCreatedPackage: true.
  2. If no new package should be created, set needCreatedPackage: false instead of omitting packageInfo.
  3. Ensure packageInfo is a real object, not null, in the serialized arguments.
  4. Validate plan shape client-side before calling the tool (see validationCode).

Example fix

// before
{ packageName: "order-center", packageType: "plugin", needCreatedPackage: true }

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

Strategy: validation

Validate before calling

function requirePackageInfo(plan) {
  if (plan.needCreatedPackage && (plan.packageInfo == null || typeof plan.packageInfo !== 'object')) {
    throw new Error('needCreatedPackage=true requires a packageInfo object');
  }
  return plan;
}

Type guard

function hasPackageInfoWhenCreating(plan) {
  return !plan.needCreatedPackage || (plan.packageInfo != null && typeof plan.packageInfo === 'object');
}

Try / catch

try {
  return await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
  if (String(err.message).includes('packageInfo 不能为空')) {
    plan.needCreatedPackage = false; // or fill plan.packageInfo = buildDefaultPackageInfo(plan)
    return callTool('gva_execute', { executionPlan: plan });
  }
  throw err;
}

Prevention

When it happens

Trigger: executionPlan has `needCreatedPackage: true` but the `packageInfo` object is missing entirely (or explicitly null) from the plan JSON.

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

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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