flipped-aurora/gin-vue-admin · error
packageType 必须是 'package' 或 'plugin'
Error message
packageType 必须是 'package' 或 'plugin'
What it means
validateExecutionPlan enforces that plan.PackageType is exactly one of the two supported template kinds: "package" or "plugin". Any other value (empty, different casing, or an arbitrary string) is rejected because the downstream generator can only dispatch to those two workflows.
Source
Thrown at server/mcp/gva_execute.go:294
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'")
}
if plan.PackageInfo.Label == "" {
return errors.New("packageInfo.label 不能为空")View on GitHub (pinned to 3136500ef3)
Solutions
- Set `packageType` to exactly "package" or "plugin" (lowercase).
- Normalize the value before sending: strings.ToLower + whitelist check.
- If the type is chosen dynamically, validate against ["package","plugin"] and reject other values early.
- If an additional type is genuinely needed, extend validateExecutionPlan's whitelist in server/mcp/gva_execute.go.
Example fix
// before
const plan = { packageName: "order-center", packageType: "Plugin" }
// after
const plan = { packageName: "order-center", packageType: "plugin" } Defensive patterns
Strategy: validation
Validate before calling
const PACKAGE_TYPES = ['package', 'plugin'];
function requireValidPackageType(plan) {
if (!PACKAGE_TYPES.includes(plan?.packageType)) {
throw new Error(`packageType must be one of ${PACKAGE_TYPES.join('|')}, got: ${plan?.packageType}`);
}
return plan;
} Type guard
function isPackageType(v) {
return v === 'package' || v === 'plugin';
} Try / catch
try {
return await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
if (String(err.message).includes("packageType 必须是")) {
const normalized = String(plan.packageType).toLowerCase();
plan.packageType = isPackageType(normalized) ? normalized : 'package';
return callTool('gva_execute', { executionPlan: plan });
}
throw err;
} Prevention
- Use a shared enum/constant for packageType instead of free-form strings
- Lowercase-normalize input before assigning
- Restrict plan-building UIs to a dropdown with exactly these two options
When it happens
Trigger: executionPlan contains `packageType` set to "", "Package", "packages", "api", or any value other than the exact lowercase literals "package" or "plugin".
Common situations: Case-sensitivity mistakes ("Plugin"); LLM-generated plans inventing a type; older client code using a deprecated type name that no longer matches the accepted literals.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- packageInfo.template 必须是 'package' 或 'plugin'
- 参数错误:executionPlan 必须提供
- packageName 不能为空
- packageType 和 packageInfo.template 必须保持一致
- 当 needCreatedPackage=true 时,packageInfo 不能为空
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/ed991bea5504a3a1.
Report an issue: GitHub.