{"record":{"id":"a5ceefb88c8d89da","repo":"flipped-aurora/gin-vue-admin","slug":"filpath-s-a5ceef","errorCode":null,"errorMessage":"[filpath:%s]非法模版文件夹!","messagePattern":"\\[filpath:(.+?)\\]非法模版文件夹!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":361,"sourceCode":"\t\t\t\t\t\tcreates[three] = pluginInitialize.Path\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版文件!\", three)\n\t\t\t\t}\n\t\t\t\tswitch secondDirs[j].Name() {\n\t\t\t\tcase \"api\", \"router\", \"service\":\n\t\t\t\t\tvar threeDirs []os.DirEntry\n\t\t\t\t\tthreeDirs, err = os.ReadDir(three)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, nil, nil, errors.Wrapf(err, \"读取模版文件夹[%s]失败!\", three)\n\t\t\t\t\t}\n\t\t\t\t\tfor k := 0; k < len(threeDirs); k++ {\n\t\t\t\t\t\tif threeDirs[k].Name() == \".DS_Store\" {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfour := filepath.Join(three, threeDirs[k].Name())\n\t\t\t\t\t\tif threeDirs[k].IsDir() {\n\t\t\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版文件夹!\", four)\n\t\t\t\t\t\t}\n\t\t\t\t\t\text := filepath.Ext(four)\n\t\t\t\t\t\tif ext != \".tpl\" {\n\t\t\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版后缀!\", four)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tapi := strings.Index(threeDirs[k].Name(), \"api\")\n\t\t\t\t\t\thasEnter := strings.Index(threeDirs[k].Name(), \"enter\")\n\t\t\t\t\t\trouter := strings.Index(threeDirs[k].Name(), \"router\")\n\t\t\t\t\t\tservice := strings.Index(threeDirs[k].Name(), \"service\")\n\t\t\t\t\t\tif router == -1 && api == -1 && service == -1 && hasEnter == -1 {\n\t\t\t\t\t\t\treturn nil, nil, nil, errors.Errorf(\"[filpath:%s]非法模版文件!\", four)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif entity.Template == \"package\" {\n\t\t\t\t\t\t\tcreate := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, secondDirs[j].Name(), entity.PackageName, info.HumpPackageName+\".go\")\n\t\t\t\t\t\t\tif api != -1 {\n\t\t\t\t\t\t\t\tcreate = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, secondDirs[j].Name(), \"v1\", entity.PackageName, info.HumpPackageName+\".go\")\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif hasEnter != -1 {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L343-L379","documentation":"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]非法模版文件夹!\").","triggerScenarios":"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.","commonSituations":"Users organizing templates into subfolders; archive extraction leaving __MACOSX or resource fork dirs; accidentally cloning a git repo into the template folder (.git dir).","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."],"exampleFix":"// before\nserver/api/v1/system_api.go.tpl\n// after\nmv server/api/v1/system_api.go.tpl server/api/ && rmdir server/api/v1","handlingStrategy":"validation","validationCode":"for _, d := range []string{\"api\", \"router\", \"service\"} {\n    entries, _ := os.ReadDir(filepath.Join(templateDir, \"server\", d))\n    for _, e := range entries {\n        if e.IsDir() && e.Name() != \".DS_Store\" {\n            return fmt.Errorf(\"%s/%s 不允许子目录\", d, e.Name())\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := generate(); err != nil && strings.Contains(err.Error(), \"非法模版文件夹\") {\n    return fmt.Errorf(\"api/router/service 内不允许嵌套目录，请扁平化: %w\", err)\n}","preventionTips":["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"],"tags":["codegen","go","validation","templates"],"backgroundTag":"invalid-template-directory","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}