{"record":{"id":"ee57f12b40b613fb","repo":"gastownhall/beads","slug":"server-diagnostics-failed-w","errorCode":null,"errorMessage":"server diagnostics failed: %w","messagePattern":"server diagnostics failed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/perf_dolt.go","lineNumber":95,"sourceCode":"\n\t// Start profiling if requested\n\tif enableProfiling {\n\t\tprofilePath := fmt.Sprintf(\"beads-dolt-perf-%s.prof\", time.Now().Format(\"2006-01-02-150405\"))\n\t\tif profileFile, err := startCPUProfile(profilePath); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to start CPU profiling: %v\\n\", err)\n\t\t} else {\n\t\t\tmetrics.ProfilePath = profilePath\n\t\t\tdefer stopCPUProfile(profileFile)\n\t\t}\n\t}\n\n\t// Connect and run diagnostics via server\n\tif !serverRunning {\n\t\treturn metrics, fmt.Errorf(\"dolt sql-server is not running on %s:%d; start it with 'bd dolt start'\", dsCfg.Host, dsCfg.Port)\n\t}\n\n\tif err := runDoltServerDiagnostics(metrics, dsCfg.Host, dsCfg.Port, dbName, beadsDir); err != nil {\n\t\treturn metrics, fmt.Errorf(\"server diagnostics failed: %w\", err)\n\t}\n\n\t// Calculate database size\n\tmetrics.DatabaseSize = getDoltDatabaseSize(doltDir)\n\n\treturn metrics, nil\n}\n\n// runDoltServerDiagnostics runs diagnostics via dolt sql-server\nfunc runDoltServerDiagnostics(metrics *DoltPerfMetrics, host string, port int, dbName string, beadsDir string) error {\n\tmetrics.Backend = \"dolt-server\"\n\tmetrics.ServerMode = true\n\n\t// Resolve credentials from config and environment, matching openDoltDB behavior.\n\t// GetDoltServerPasswordForPort checks BEADS_DOLT_PASSWORD env first, then\n\t// falls back to ~/.config/beads/credentials keyed by [host:port] — required\n\t// for externally-hosted Dolt servers (bd-h5k7).\n\tuser := configfile.DefaultDoltServerUser","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/perf_dolt.go#L77-L113","documentation":"runDoltServerDiagnostics (which opens a MySQL connection and runs diagnostic queries) failed; its error is wrapped with 'server diagnostics failed:'. The wrapped cause contains the actual problem (open, ping, or query failure).","triggerScenarios":"RunDoltPerformanceDiagnostics -> runDoltServerDiagnostics returns non-nil: sql.Open failure, ping timeout, or a diagnostic SQL query error.","commonSituations":"Server accepting TCP but rejecting auth (bad DSN credentials); database name wrong; queries failing due to schema drift or permissions; 30s ping timeout on a loaded server.","solutions":["Inspect the wrapped %w cause for open/ping/query detail","Confirm credentials and database name in the Dolt server config","Check server logs for query errors; ensure the beads schema is up to date ('bd doctor', migrations)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if !serverReachable(host, port) { return }\n// also verify schema: SELECT 1 FROM issues LIMIT 1 succeeds","typeGuard":null,"tryCatchPattern":"if err != nil && strings.HasPrefix(err.Error(), \"server diagnostics failed:\") {\n    cause := errors.Unwrap(err)\n    log.Printf(\"dolt server diagnostics: %v\", cause)\n}","preventionTips":["Verify connectivity and auth before long diagnostic runs","Keep beads schema migrated to the current bd version","Watch dolt sql-server logs during doctor runs"],"tags":["beads","dolt","sql","wrapping"],"backgroundTag":"server-diagnostics-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}