flipped-aurora/gin-vue-admin · error
packageInfo.template 必须是 'package' 或 'plugin'
Error message
packageInfo.template 必须是 'package' 或 'plugin'
What it means
validateExecutionPlan requires that packageInfo.template, when package creation is requested, is exactly "package" or "plugin" — the same enum as the top-level packageType, because this field drives the code-generation template selection. Other values (including different casing) are rejected.
Source
Thrown at server/mcp/gva_execute.go:309
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 {
if moduleInfo.Package == "" {
return fmt.Errorf("模块 %d 的 package 不能为空", moduleIndex+1)
}View on GitHub (pinned to 3136500ef3)
Solutions
- Set packageInfo.template to exactly "package" or "plugin" (lowercase).
- Sync it with the top-level packageType (they must match — see error 23).
- Normalize/validate the value against the whitelist before sending.
- Ensure the source of the value (form/config) only offers these two options.
Example fix
// before
packageInfo: { packageName: "order-center", template: "Plugin", label: "订单中心", desc: "..." }
// after
packageInfo: { packageName: "order-center", template: "plugin", label: "订单中心", desc: "..." } Defensive patterns
Strategy: validation
Validate before calling
function requireValidNestedTemplate(plan) {
if (plan.needCreatedPackage && !['package', 'plugin'].includes(plan.packageInfo?.template)) {
throw new Error(`packageInfo.template must be 'package' or 'plugin', got: ${plan.packageInfo?.template}`);
}
return plan;
} Type guard
function hasValidNestedTemplate(plan) {
return !plan.needCreatedPackage || plan.packageInfo?.template === 'package' || plan.packageInfo?.template === 'plugin';
} Try / catch
try {
return await callTool('gva_execute', { executionPlan: plan });
} catch (err) {
if (String(err.message).includes("packageInfo.template 必须是")) {
const normalized = String(plan.packageInfo.template).toLowerCase();
plan.packageInfo.template = ['package', 'plugin'].includes(normalized) ? normalized : plan.packageType;
return callTool('gva_execute', { executionPlan: plan });
}
throw err;
} Prevention
- Reuse the same enum/constant for packageInfo.template as for packageType
- Set template: packageType when constructing packageInfo so they never diverge
- Restrict template inputs in UIs to the two allowed literals
When it happens
Trigger: executionPlan with needCreatedPackage=true and packageInfo.template set to "", "Plugin", "module", or any string other than the exact lowercase literals "package"/"plugin".
Common situations: UI dropdown defaulting to an empty value; LLM writing a human-friendly template name; older plan format using different template identifiers that no longer match the whitelist.
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
- packageType 必须是 '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/2a5ce3fba87a5f78.
Report an issue: GitHub.