{"record":{"id":"4f5e4cb1c51fe9c8","repo":"flipped-aurora/gin-vue-admin","slug":"error-4f5e4c","errorCode":null,"errorMessage":"获取所有包失败!","messagePattern":"获取所有包失败!","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":209,"sourceCode":"\t\t\t\t\tmissingDirs = append(missingDirs, dirName)\n\t\t\t\t}\n\t\t\t\tdesc = fmt.Sprintf(\"系统自动读取，但是缺少 %s 结构，不建议自动化和mcp使用\", strings.Join(missingDirs, \"、\"))\n\t\t\t}\n\n\t\t\tpluginPackage := model.SysAutoCodePackage{\n\t\t\t\tPackageName: pluginDir[i].Name(),\n\t\t\t\tTemplate:    \"plugin\",\n\t\t\t\tLabel:       pluginDir[i].Name() + \"插件\",\n\t\t\t\tDesc:        desc,\n\t\t\t\tModule:      global.GVA_CONFIG.AutoCode.Module,\n\t\t\t}\n\t\t\tplugin = append(plugin, pluginPackage)\n\t\t}\n\t}\n\n\terr = global.GVA_DB.WithContext(ctx).Find(&entities).Error\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"获取所有包失败!\")\n\t}\n\tentitiesMap := make(map[string]model.SysAutoCodePackage)\n\tfor i := 0; i < len(entities); i++ {\n\t\tentitiesMap[entities[i].PackageName] = entities[i]\n\t}\n\tcreateEntity := []model.SysAutoCodePackage{}\n\tfor i := 0; i < len(server); i++ {\n\t\tif _, ok := entitiesMap[server[i].PackageName]; !ok {\n\t\t\tif server[i].Template == \"package\" {\n\t\t\t\tcreateEntity = append(createEntity, server[i])\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < len(plugin); i++ {\n\t\tif _, ok := entitiesMap[plugin[i].PackageName]; !ok {\n\t\t\tif plugin[i].Template == \"plugin\" {\n\t\t\t\tcreateEntity = append(createEntity, plugin[i])\n\t\t\t}","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L191-L227","documentation":"After scanning the filesystem, All queries all SysAutoCodePackage rows from the database to reconcile them with directories found on disk. This error wraps any failure of that SELECT, meaning the DB lookup of existing packages failed.","triggerScenarios":"Calling autoCodePackage.All when global.GVA_DB is unreachable/invalid, the sys_auto_code_packages table is missing (no migration), or the query errors (lock timeout, dropped connection).","commonSituations":"Fresh environment without AutoMigrate of the auto-code tables; DB credentials/network changed; database restarted mid-request; read-only replica used for writes environment by mistake.","solutions":["Read the wrapped inner error for the concrete DB failure","Verify DB connectivity and that sys_auto_code_packages exists (run migrations/AutoMigrate)","Restore DB service or fix credentials in config.yaml","Retry the operation after transient network issues"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err = global.GVA_DB.WithContext(ctx).Find(&entities).Error\nif err != nil {\n    if isRetryable(err) {\n        return retryWithBackoff(func() error { return syncPackages(ctx) })\n    }\n    return nil, errors.Wrap(err, \"获取所有包失败!\")\n}","preventionTips":["AutoMigrate sys_auto_code_packages at startup","Add DB health/readiness probes before serving admin APIs","Handle connection drops with retry middleware","Point config at the correct primary DB, not a read-only replica, for write-capable endpoints"],"tags":["database","gorm","select","sync"],"backgroundTag":"gorm-query-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}