flipped-aurora/gin-vue-admin · error
packageName 不能为空
Error message
packageName 不能为空
What it means
validateExecutionPlan checks the decoded ExecutionPlan struct before execution proceeds. The first check requires plan.PackageName to be a non-empty string, since the executor must know which package/plugin resource to generate. An empty PackageName means the plan is unidentifiable and the executor refuses to run.
Source
Thrown at server/mcp/gva_execute.go:291
NextActions: result.NextActions,
}
responseJSON, err := json.MarshalIndent(response, "", " ")
if err != nil {
return nil, fmt.Errorf("序列化结果失败: %v", err)
}
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'")View on GitHub (pinned to 3136500ef3)
Solutions
- Set `packageName` to the target package/plugin's name in the executionPlan object.
- Confirm the JSON field name is `packageName` (matches the struct tag) so it binds to ExecutionPlan.PackageName.
- Validate the plan client-side before calling the tool (see validationCode).
- If the name comes from user input, trim whitespace and re-check non-empty before sending.
Example fix
// before
const plan = { packageType: "plugin", needCreatedPackage: true }
// after
const plan = { packageName: "order-center", packageType: "plugin", needCreatedPackage: true } Defensive patterns
Strategy: validation
Validate before calling
function requirePackageName(plan) {
if (!plan || typeof plan.packageName !== 'string' || plan.packageName.trim() === '') {
throw new Error('executionPlan.packageName is required and must be non-empty');
}
return plan;
}
// call: requirePackageName(plan) before invoking gva_execute Type guard
function hasPackageName(plan) {
return typeof plan?.packageName === 'string' && plan.packageName.trim().length > 0;
} Try / catch
try {
const result = await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
if (String(err.message).includes('packageName 不能为空')) {
plan.packageName = plan.packageName?.trim() || deriveNameFromLabel(plan);
return callTool('gva_execute', { executionPlan: plan });
}
throw err;
} Prevention
- Validate the plan against its JSON schema client-side before every tool call
- Trim and check user-supplied names before placing them into the plan
- Use consistent camelCase keys matching the Go struct tags
When it happens
Trigger: Calling the gva_execute tool with executionPlan present but its `packageName` field empty ("") or omitted, then Handle unmarshals the plan and invokes validateExecutionPlan.
Common situations: An LLM agent generated a plan skeleton and left packageName blank; a template filled in with an empty variable; the field was named `package_name` in the payload so Go unmarshaling left PackageName at its zero value.
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
- packageInfo.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/c3229de036d5bd47.
Report an issue: GitHub.