{"record":{"id":"0c6655fc7157ef96","repo":"flipped-aurora/gin-vue-admin","slug":"plugin","errorCode":null,"errorMessage":"读取plugin文件夹失败!","messagePattern":"读取plugin文件夹失败!","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":146,"sourceCode":"\t}\n\treturn nil\n}\n\n// All 获取所有包\n// @author: [piexlmax](https://github.com/piexlmax)\n// @author: [SliverHorn](https://github.com/SliverHorn)\nfunc (s *autoCodePackage) All(ctx context.Context) (entities []model.SysAutoCodePackage, err error) {\n\tserver := make([]model.SysAutoCodePackage, 0)\n\tplugin := make([]model.SysAutoCodePackage, 0)\n\tserverPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"service\")\n\tpluginPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\")\n\tserverDir, err := os.ReadDir(serverPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"读取service文件夹失败!\")\n\t}\n\tpluginDir, err := os.ReadDir(pluginPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"读取plugin文件夹失败!\")\n\t}\n\tfor i := 0; i < len(serverDir); i++ {\n\t\tif serverDir[i].IsDir() {\n\t\t\tserverPackage := model.SysAutoCodePackage{\n\t\t\t\tPackageName: serverDir[i].Name(),\n\t\t\t\tTemplate:    \"package\",\n\t\t\t\tLabel:       serverDir[i].Name() + \"包\",\n\t\t\t\tDesc:        \"系统自动读取\" + serverDir[i].Name() + \"包\",\n\t\t\t\tModule:      global.GVA_CONFIG.AutoCode.Module,\n\t\t\t}\n\t\t\tserver = append(server, serverPackage)\n\t\t}\n\t}\n\tfor i := 0; i < len(pluginDir); i++ {\n\t\tif pluginDir[i].IsDir() {\n\t\t\tdirNameMap := map[string]bool{\n\t\t\t\t\"api\":        true,\n\t\t\t\t\"config\":     true,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L128-L164","documentation":"Same filesystem-scan logic as the service scan, but for the plugin directory: All calls os.ReadDir on <AutoCode.Root>/<AutoCode.Server>/plugin and wraps any failure with this message. It indicates the plugin directory cannot be read.","triggerScenarios":"Calling autoCodePackage.All when the plugin directory under the configured server root does not exist or is not readable — no plugin directory was ever created in this checkout, or Root/Server config is wrong.","commonSituations":"Fresh/trimmed checkout where server/plugin was never created; customized repo that dropped the plugin folder; misconfigured auto-code root in config.yaml.","solutions":["Create the missing server/plugin directory (an empty one satisfies the scan)","Fix AutoCode.Root/AutoCode.Server in config.yaml to point at the real server tree","Check directory read permissions for the running user","Guard the scan with os.Stat before ReadDir if plugin may legitimately be absent"],"exampleFix":"// before: hard failure when plugin dir missing\npluginDir, err := os.ReadDir(pluginPath)\nif err != nil {\n    return nil, errors.Wrap(err, \"读取plugin文件夹失败!\")\n}\n// after: tolerate absence\nif _, statErr := os.Stat(pluginPath); os.IsNotExist(statErr) {\n    pluginDir = []os.DirEntry{}\n} else if pluginDir, err = os.ReadDir(pluginPath); err != nil {\n    return nil, errors.Wrap(err, \"读取plugin文件夹失败!\")\n}","handlingStrategy":"validation","validationCode":"pluginPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, \"plugin\")\nif info, err := os.Stat(pluginPath); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"plugin dir missing at %s\", pluginPath)\n}","typeGuard":null,"tryCatchPattern":"pluginDir, err := os.ReadDir(pluginPath)\nif err != nil {\n    if os.IsNotExist(err) {\n        pluginDir = []os.DirEntry{}\n    } else {\n        return nil, errors.Wrap(err, \"读取plugin文件夹失败!\")\n    }\n}","preventionTips":["Create server/plugin at bootstrap even if empty","Validate auto-code root/server config values at startup","Ensure read permission on plugin directory for the service user","Treat optional directories explicitly instead of failing the whole scan"],"tags":["filesystem","directory-not-found","config","codegen"],"backgroundTag":"directory-not-found","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}