{"record":{"id":"6157c32b0142351d","repo":"gastownhall/beads","slug":"failed-to-list-federation-peers-w","errorCode":null,"errorMessage":"failed to list federation peers: %w","messagePattern":"failed to list federation peers: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/credentials.go","lineNumber":370,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to initialize credential key: %w\", err)\n\t\t}\n\t\tpeer.Password, err = s.decryptPassword(encryptedPwd)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to decrypt password: %w\", err)\n\t\t}\n\t}\n\n\treturn &peer, nil\n}\n\n// ListFederationPeers returns all configured federation peers.\nfunc (s *DoltStore) ListFederationPeers(ctx context.Context) ([]*storage.FederationPeer, error) {\n\trows, err := s.queryContext(ctx, `\n\t\tSELECT name, remote_url, username, password_encrypted, sovereignty, last_sync, created_at, updated_at\n\t\tFROM federation_peers ORDER BY name\n\t`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list federation peers: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\tvar peers []*storage.FederationPeer\n\tfor rows.Next() {\n\t\tvar peer storage.FederationPeer\n\t\tvar encryptedPwd []byte\n\t\tvar lastSync sql.NullTime\n\t\tvar username sql.NullString\n\n\t\tif err := rows.Scan(&peer.Name, &peer.RemoteURL, &username, &encryptedPwd, &peer.Sovereignty, &lastSync, &peer.CreatedAt, &peer.UpdatedAt); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to scan federation peer: %w\", err)\n\t\t}\n\n\t\tif username.Valid {\n\t\t\tpeer.Username = username.String\n\t\t}\n\t\tif lastSync.Valid {","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/credentials.go#L352-L388","documentation":"ListFederationPeers runs a SELECT over the federation_peers table and returns all configured peers. This error wraps any failure executing that query against the Dolt database — the table is missing, the connection to the SQL server is down, or the query is cancelled. The library throws it so callers get a descriptive error instead of a raw driver error.","triggerScenarios":"Calling ListFederationPeers when the federation_peers table doesn't exist yet (fresh DB before any AddFederationPeer/`bd init` migration ran), the dolt-sql-server connection has been dropped, or ctx is cancelled mid-query.","commonSituations":"Running `bd federation` style listing against a server-mode Dolt instance that was restarted; pointing bd at a database created by an older beads version lacking the table; network drops to a remote dolt-sql-server.","solutions":["Verify the database is reachable: restart the dolt-sql-server or re-open the embedded store.","Ensure the schema is up to date — run bd's init/migration so federation_peers exists (SELECT * FROM federation_peers LIMIT 1 to test).","Check ctx cancellation: pass context.Background() or a non-expired context if this fires spuriously.","If the table is truly absent on a fresh install, treat it as an empty peer list rather than an error in your tooling."],"exampleFix":"// before\npeers, err := store.ListFederationPeers(ctx) // failed to list federation peers: ...table doesn't exist\n// after: initialize schema first\nif err := store.Init(ctx); err != nil { return err }\npeers, err := store.ListFederationPeers(ctx)","handlingStrategy":"try-catch","validationCode":"// pre-check table accessibility\nrow := db.QueryRowContext(ctx, \"SELECT COUNT(*) FROM federation_peers\")\nvar n int\nif err := row.Scan(&n); err != nil { /* table missing or DB down */ }","typeGuard":null,"tryCatchPattern":"peers, err := store.ListFederationPeers(ctx)\nif err != nil {\n    var notFound *storage.ErrNotFound\n    log.Printf(\"listing peers failed (empty or unreachable DB?): %v\", err)\n    peers = nil\n}","preventionTips":["Run bd init/migrations before calling federation APIs on a fresh database","Keep the dolt-sql-server reachable and monitor its health","Pass a non-cancelled context to long listing operations","Align bd binary version with the database schema version"],"tags":["database","sql","federation","query"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}