flipped-aurora/gin-vue-admin · error
invalid plugin type
Error message
invalid plugin type
What it means
autoCodePlugin.Remove deletes an installed plugin's files and deregisters its import. It only accepts pluginType values "web", "server", or "full"; any other string is rejected with "invalid plugin type" before any filesystem work happens.
Source
Thrown at server/service/system/auto_code_plugin.go:902
return err
}
var dictionaries []system.SysDictionary
err = global.GVA_DB.WithContext(ctx).Preload("SysDictionaryDetails").Find(&dictionaries, "id in (?)", dictInfo.Dictionaries).Error
if err != nil {
return err
}
dictExpr := ast.CreateDictionaryStructAst(dictionaries)
arrayAst.Elts = *dictExpr
return writePluginInitializeFile(dictPath, fileSet, astFile)
}
func (s *autoCodePlugin) Remove(ctx context.Context, pluginName string, pluginType string) (err error) {
if err = utils.ValidatePluginName(pluginName); err != nil {
return err
}
if pluginType != "web" && pluginType != "server" && pluginType != "full" {
return errors.New("invalid plugin type")
}
var webDir, serverDir string
if pluginType == "web" || pluginType == "full" {
webDir, err = pluginPath(global.GVA_CONFIG.AutoCode.Web, pluginName)
if err != nil {
return err
}
}
if pluginType == "server" || pluginType == "full" {
serverDir, err = pluginPath(global.GVA_CONFIG.AutoCode.Server, pluginName)
if err != nil {
return err
}
}
// 1. 删除前端代码
if pluginType == "web" || pluginType == "full" {View on GitHub (pinned to 3136500ef3)
Solutions
- Pass exactly "web", "server", or "full" (lowercase) as pluginType.
- Map UI-side values to these three literals before invoking Remove.
- Update stale API clients or documentation using older type names.
Example fix
// before s.Remove(ctx, "myplugin", "Frontend") // after s.Remove(ctx, "myplugin", "web")
Defensive patterns
Strategy: validation
Validate before calling
var allowed = map[string]bool{"web": true, "server": true, "full": true}
if !allowed[pluginType] {
return fmt.Errorf("pluginType 必须是 web/server/full, 收到: %q", pluginType)
}
// safe to call Remove Type guard
func isValidPluginType(t string) bool {
return t == "web" || t == "server" || t == "full"
} Try / catch
if err := plugService.Remove(ctx, name, pluginType); err != nil {
if err.Error() == "invalid plugin type" {
return fmt.Errorf("仅支持 web/server/full: %w", err)
}
return err
} Prevention
- Constrain UI selects to the three literals web/server/full.
- Normalize/lowercase user input before calling Remove.
- Share a constant set between frontend and backend instead of free-form strings.
- Add API-layer binding validation (oneof=web server full).
When it happens
Trigger: Calling Remove with pluginType not exactly one of "web"/"server"/"full" — e.g. "frontend", "backend", "all", empty string, or wrong casing ("Web").
Common situations: Frontend UI sending a translated or legacy type value; API consumers guessing the parameter; case-sensitivity mistakes when calling the service directly.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/28b3f1ed38fed955.
Report an issue: GitHub.