flipped-aurora/gin-vue-admin · error

获取包信息失败: %v

Error message

获取包信息失败: %v

What it means

performAnalysis fails at server/mcp/gva_analyze.go:100 when fetchAutoCodePackages cannot retrieve the list of autocode packages from the backend (database or service layer). The tool aborts the snapshot build and this wrapped error propagates up through Handle as "分析失败: 获取包信息失败: ...".

Source

Thrown at server/mcp/gva_analyze.go:100

	}

	// 执行分析逻辑
	response, err := g.performAnalysis(ctx, analyzeReq)
	if err != nil {
		return nil, fmt.Errorf("分析失败: %v", err)
	}

	// 序列化响应
	return textResultWithJSON("", response)
}

// performAnalysis 执行分析逻辑
func (g *GVAAnalyzer) performAnalysis(ctx context.Context, req AnalyzeRequest) (*AnalyzeResponse, error) {
	_ = req

	packages, err := fetchAutoCodePackages(ctx)
	if err != nil {
		return nil, fmt.Errorf("获取包信息失败: %v", err)
	}

	histories, err := fetchAutoCodeHistories(ctx)
	if err != nil {
		return nil, fmt.Errorf("获取历史记录失败: %v", err)
	}

	cleanupInfo := &CleanupInfo{
		DeletedPackages: []string{},
		DeletedModules:  []string{},
	}

	validPackages := make([]PackageInfo, 0, len(packages))
	var emptyPackageHistoryIDs []uint

	for _, pkg := range packages {
		isEmpty, err := g.isPackageFolderEmpty(pkg.PackageName, pkg.Template)
		if err != nil {

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Look at the wrapped error after the prefix to find the root cause (connection refused / no such table / unauthorized).
  2. Confirm the database is reachable and auto-migration has created the autocode package tables.
  3. Re-authenticate so the caller's ctx holds a valid JWT before calling gva_analyze.
  4. Check config.yaml database settings match the running DB instance.
  5. Retry gva_analyze after restoring the DB connection.

Example fix

// before: gva_analyze called with dead DB
// 分析失败: 获取包信息失败: dial tcp 127.0.0.1:3306: connect: connection refused
// after: start MySQL / fix config.yaml db settings, then retry gva_analyze
Defensive patterns

Strategy: retry

Validate before calling

// ensure DB reachable before invoking
const up = await dbPing().catch(() => false)
if (!up) throw new Error('database unreachable; fix before gva_analyze')

Try / catch

for (let attempt = 0; attempt < 3; attempt++) {
  try { return await callTool('gva_analyze', {}) }
  catch (e) {
    if (!String(e.message).includes('获取包信息失败')) throw e
    await sleep(1000 * (attempt + 1))
  }
}

Prevention

When it happens

Trigger: Calling the gva_analyze MCP tool when the package query fails: DB connection refused, table sys_auto_code (packages) missing/not migrated, invalid auth token in ctx, or the underlying service returning an error.

Common situations: Fresh deployments where migrations haven't run; database credentials changed in config.yaml; token expired so the request ctx is unauthenticated; DB temporarily down.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/5ac563e58eca2e24. Report an issue: GitHub.