flipped-aurora/gin-vue-admin · error
[filpath:%s]非法模版文件夹!
Error message
[filpath:%s]非法模版文件夹!
What it means
Inside server/{api,router,service} templates, subdirectories are forbidden: the generator expects only flat .tpl files. Finding a directory there aborts with errors.Errorf("[filpath:%s]非法模版文件夹!").
Source
Thrown at server/service/system/auto_code_package.go:361
creates[three] = pluginInitialize.Path
continue
}
return nil, nil, nil, errors.Errorf("[filpath:%s]非法模版文件!", three)
}
switch secondDirs[j].Name() {
case "api", "router", "service":
var threeDirs []os.DirEntry
threeDirs, err = os.ReadDir(three)
if err != nil {
return nil, nil, nil, errors.Wrapf(err, "读取模版文件夹[%s]失败!", three)
}
for k := 0; k < len(threeDirs); k++ {
if threeDirs[k].Name() == ".DS_Store" {
continue
}
four := filepath.Join(three, threeDirs[k].Name())
if threeDirs[k].IsDir() {
return nil, nil, nil, errors.Errorf("[filpath:%s]非法模版文件夹!", four)
}
ext := filepath.Ext(four)
if ext != ".tpl" {
return nil, nil, nil, errors.Errorf("[filpath:%s]非法模版后缀!", four)
}
api := strings.Index(threeDirs[k].Name(), "api")
hasEnter := strings.Index(threeDirs[k].Name(), "enter")
router := strings.Index(threeDirs[k].Name(), "router")
service := strings.Index(threeDirs[k].Name(), "service")
if router == -1 && api == -1 && service == -1 && hasEnter == -1 {
return nil, nil, nil, errors.Errorf("[filpath:%s]非法模版文件!", four)
}
if entity.Template == "package" {
create := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, secondDirs[j].Name(), entity.PackageName, info.HumpPackageName+".go")
if api != -1 {
create = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, secondDirs[j].Name(), "v1", entity.PackageName, info.HumpPackageName+".go")
}
if hasEnter != -1 {View on GitHub (pinned to 3136500ef3)
Solutions
- Flatten the structure: move the .tpl files up into the api/router/service folder itself and delete the subdirectory.
- Remove junk directories (.git, __MACOSX, .idea) from the template tree.
- Re-extract template archives with junk-path flattening or clean them afterwards.
- Keep one .tpl per generated file, no grouping subfolders.
Example fix
// before server/api/v1/system_api.go.tpl // after mv server/api/v1/system_api.go.tpl server/api/ && rmdir server/api/v1
Defensive patterns
Strategy: validation
Validate before calling
for _, d := range []string{"api", "router", "service"} {
entries, _ := os.ReadDir(filepath.Join(templateDir, "server", d))
for _, e := range entries {
if e.IsDir() && e.Name() != ".DS_Store" {
return fmt.Errorf("%s/%s 不允许子目录", d, e.Name())
}
}
} Try / catch
if err := generate(); err != nil && strings.Contains(err.Error(), "非法模版文件夹") {
return fmt.Errorf("api/router/service 内不允许嵌套目录,请扁平化: %w", err)
} Prevention
- Keep api/router/service template folders flat: one .tpl per file
- Exclude __MACOSX, .git, .idea when extracting or copying template archives
- Move grouped templates up one level before generating
- Run a lint script over resource/ that fails CI on nested dirs
When it happens
Trigger: A nested folder (e.g. api/v1/, service/sub/, .git/, node_modules, __MACOSX) inside any of the api/router/service template directories during package/plugin generation.
Common situations: Users organizing templates into subfolders; archive extraction leaving __MACOSX or resource fork dirs; accidentally cloning a git repo into the template folder (.git dir).
Related errors
- [filpath:%s]非法模版后缀!
- [filpath:%s]非法模版文件!
- 参数错误:executionPlan 必须提供
- packageName 不能为空
- packageType 必须是 'package' 或 'plugin'
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/a5ceefb88c8d89da.
Report an issue: GitHub.