flipped-aurora/gin-vue-admin · error
packageInfo.packageName 不能为空
Error message
packageInfo.packageName 不能为空
What it means
Inside the NeedCreatedPackage block, validateExecutionPlan checks each required packageInfo field. The nested PackageInfo.PackageName must be non-empty; it is the name used when actually generating the new package/plugin and can differ from the top-level packageName. An empty nested name would produce an unnamed artifact.
Source
Thrown at server/mcp/gva_execute.go:306
// 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 不能为空")
}
for moduleIndex, moduleInfo := range plan.ModulesInfo {View on GitHub (pinned to 3136500ef3)
Solutions
- Set packageInfo.packageName to the new package/plugin's name.
- Or copy the top-level packageName into packageInfo if they should be the same.
- Confirm JSON key casing (`packageName`) so it binds to the struct field.
- Validate all required packageInfo fields client-side before invoking.
Example fix
// before
packageInfo: { template: "plugin", label: "订单中心", desc: "..." }
// after
packageInfo: { packageName: "order-center", template: "plugin", label: "订单中心", desc: "..." } Defensive patterns
Strategy: validation
Validate before calling
function requireNestedPackageName(plan) {
if (plan.needCreatedPackage && (!plan.packageInfo || !plan.packageInfo.packageName?.trim())) {
throw new Error('packageInfo.packageName is required when needCreatedPackage=true');
}
return plan;
} Type guard
function hasNestedPackageName(plan) {
return !plan.needCreatedPackage || (typeof plan.packageInfo?.packageName === 'string' && plan.packageInfo.packageName.trim().length > 0);
} Try / catch
try {
return await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
if (String(err.message).includes('packageInfo.packageName 不能为空')) {
plan.packageInfo.packageName = plan.packageName; // default from top-level name
return callTool('gva_execute', { executionPlan: plan });
}
throw err;
} Prevention
- Do not assume top-level packageName propagates — set packageInfo.packageName explicitly
- Build packageInfo with all required fields via a helper that takes name/template/label/desc
- Keep JSON key casing camelCase to match the Go struct tags
When it happens
Trigger: executionPlan with needCreatedPackage=true, packageInfo present, but packageInfo.packageName is "" or omitted (top-level packageName alone does not satisfy this check).
Common situations: Assuming the top-level packageName propagates into packageInfo; constructing packageInfo with only template/label/desc; form data where the name input was left blank.
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
- packageName 不能为空
- packageInfo.label 不能为空
- packageInfo.desc 不能为空
- 当 needCreatedModules=true 时,modulesInfo 不能为空
- 参数错误:executionPlan 必须提供
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/a75e75b6f70f78c5.
Report an issue: GitHub.