{"record":{"id":"5ac563e58eca2e24","repo":"flipped-aurora/gin-vue-admin","slug":"v-5ac563","errorCode":null,"errorMessage":"获取包信息失败: %v","messagePattern":"获取包信息失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_analyze.go","lineNumber":100,"sourceCode":"\t}\n\n\t// 执行分析逻辑\n\tresponse, err := g.performAnalysis(ctx, analyzeReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"分析失败: %v\", err)\n\t}\n\n\t// 序列化响应\n\treturn textResultWithJSON(\"\", response)\n}\n\n// performAnalysis 执行分析逻辑\nfunc (g *GVAAnalyzer) performAnalysis(ctx context.Context, req AnalyzeRequest) (*AnalyzeResponse, error) {\n\t_ = req\n\n\tpackages, err := fetchAutoCodePackages(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"获取包信息失败: %v\", err)\n\t}\n\n\thistories, err := fetchAutoCodeHistories(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"获取历史记录失败: %v\", err)\n\t}\n\n\tcleanupInfo := &CleanupInfo{\n\t\tDeletedPackages: []string{},\n\t\tDeletedModules:  []string{},\n\t}\n\n\tvalidPackages := make([]PackageInfo, 0, len(packages))\n\tvar emptyPackageHistoryIDs []uint\n\n\tfor _, pkg := range packages {\n\t\tisEmpty, err := g.isPackageFolderEmpty(pkg.PackageName, pkg.Template)\n\t\tif err != nil {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_analyze.go#L82-L118","documentation":"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 \"分析失败: 获取包信息失败: ...\".","triggerScenarios":"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.","commonSituations":"Fresh deployments where migrations haven't run; database credentials changed in config.yaml; token expired so the request ctx is unauthenticated; DB temporarily down.","solutions":["Look at the wrapped error after the prefix to find the root cause (connection refused / no such table / unauthorized).","Confirm the database is reachable and auto-migration has created the autocode package tables.","Re-authenticate so the caller's ctx holds a valid JWT before calling gva_analyze.","Check config.yaml database settings match the running DB instance.","Retry gva_analyze after restoring the DB connection."],"exampleFix":"// before: gva_analyze called with dead DB\n// 分析失败: 获取包信息失败: dial tcp 127.0.0.1:3306: connect: connection refused\n// after: start MySQL / fix config.yaml db settings, then retry gva_analyze","handlingStrategy":"retry","validationCode":"// ensure DB reachable before invoking\nconst up = await dbPing().catch(() => false)\nif (!up) throw new Error('database unreachable; fix before gva_analyze')","typeGuard":null,"tryCatchPattern":"for (let attempt = 0; attempt < 3; attempt++) {\n  try { return await callTool('gva_analyze', {}) }\n  catch (e) {\n    if (!String(e.message).includes('获取包信息失败')) throw e\n    await sleep(1000 * (attempt + 1))\n  }\n}","preventionTips":["Run auto-migrations on fresh deployments so the package table exists.","Monitor DB connectivity; transient drops cause this mid-request.","Re-authenticate when the wrapped error indicates authorization failure."],"tags":["mcp","database","autocode","go"],"backgroundTag":"database-connection-refused","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}