flipped-aurora/gin-vue-admin · error
获取所有包失败!
Error message
获取所有包失败!
What it means
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.
Source
Thrown at server/service/system/auto_code_package.go:209
missingDirs = append(missingDirs, dirName)
}
desc = fmt.Sprintf("系统自动读取,但是缺少 %s 结构,不建议自动化和mcp使用", strings.Join(missingDirs, "、"))
}
pluginPackage := model.SysAutoCodePackage{
PackageName: pluginDir[i].Name(),
Template: "plugin",
Label: pluginDir[i].Name() + "插件",
Desc: desc,
Module: global.GVA_CONFIG.AutoCode.Module,
}
plugin = append(plugin, pluginPackage)
}
}
err = global.GVA_DB.WithContext(ctx).Find(&entities).Error
if err != nil {
return nil, errors.Wrap(err, "获取所有包失败!")
}
entitiesMap := make(map[string]model.SysAutoCodePackage)
for i := 0; i < len(entities); i++ {
entitiesMap[entities[i].PackageName] = entities[i]
}
createEntity := []model.SysAutoCodePackage{}
for i := 0; i < len(server); i++ {
if _, ok := entitiesMap[server[i].PackageName]; !ok {
if server[i].Template == "package" {
createEntity = append(createEntity, server[i])
}
}
}
for i := 0; i < len(plugin); i++ {
if _, ok := entitiesMap[plugin[i].PackageName]; !ok {
if plugin[i].Template == "plugin" {
createEntity = append(createEntity, plugin[i])
}View on GitHub (pinned to 3136500ef3)
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
Defensive patterns
Strategy: try-catch
Try / catch
err = global.GVA_DB.WithContext(ctx).Find(&entities).Error
if err != nil {
if isRetryable(err) {
return retryWithBackoff(func() error { return syncPackages(ctx) })
}
return nil, errors.Wrap(err, "获取所有包失败!")
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/4f5e4cb1c51fe9c8.
Report an issue: GitHub.