{"record":{"id":"73c35065f675286a","repo":"flipped-aurora/gin-vue-admin","slug":"v-73c350","errorCode":null,"errorMessage":"获取历史记录失败: %v","messagePattern":"获取历史记录失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/gva_analyze.go","lineNumber":105,"sourceCode":"\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 {\n\t\t\tlogger.WithCtx(ctx).Mod(\"mcp\").Err(err).Warn(fmt.Sprintf(\"检查包 %s 是否为空时出错\", pkg.PackageName))\n\t\t\tcontinue\n\t\t}\n\n\t\tif isEmpty {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/gva_analyze.go#L87-L123","documentation":"performAnalysis fails at server/mcp/gva_analyze.go:105 when fetchAutoCodeHistories cannot load the autocode generation history records. The analysis aborts and the error is wrapped as \"分析失败: 获取历史记录失败: ...\". Packages may already have been fetched at this point, but no snapshot is returned.","triggerScenarios":"Calling gva_analyze when the history query fails: history table missing/not migrated, DB connection dropped between the two queries, ctx auth invalid, or service-layer error in fetchAutoCodeHistories.","commonSituations":"Partial migrations (packages table exists, history table doesn't); transient DB disconnects mid-request; expired JWT in the request context.","solutions":["Read the wrapped root error after the prefix for the actual DB/service failure.","Verify the autocode history table exists (run AutoMigrate/migrations).","Re-authenticate so ctx carries a valid token.","Check DB connectivity/stability; retry gva_analyze once healthy."],"exampleFix":"// before: history table missing\n// 分析失败: 获取历史记录失败: Error 1146: table 'gva.sys_auto_code_history' doesn't exist\n// after: run migrations to create the history table, then retry gva_analyze","handlingStrategy":"retry","validationCode":"// verify the history table exists before calling\nconst ok = await db.query(\"SELECT 1 FROM sys_auto_code_histories LIMIT 1\").then(() => true).catch(() => false)\nif (!ok) throw new Error('autocode history table missing; run migrations')","typeGuard":null,"tryCatchPattern":"try {\n  return await callTool('gva_analyze', {})\n} catch (e) {\n  if (String(e.message).includes('获取历史记录失败')) {\n    // check wrapped cause: missing table vs connection vs auth\n    throw new Error('history fetch failed: ' + e.message)\n  }\n  throw e\n}","preventionTips":["Ensure migrations create both package and history tables together.","Avoid sharing one DB session across flaky network boundaries.","Refresh expired JWTs before long MCP tool chains."],"tags":["mcp","database","autocode","go"],"backgroundTag":"database-table-missing","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}