{"record":{"id":"5196ccd791d0e85c","repo":"gastownhall/beads","slug":"list-dolt-remotes-before-credential-routing-for-pe","errorCode":null,"errorMessage":"list Dolt remotes before credential routing for peer %q: %w","messagePattern":"list Dolt remotes before credential routing for peer %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/credentials.go","lineNumber":643,"sourceCode":"\treturn err\n}\n\n// FederationPeer is an alias for storage.FederationPeer for convenience.\ntype FederationPeer = storage.FederationPeer\n\nfunc (s *DoltStore) prepareCLIRouteForPeerCredentials(ctx context.Context, peer string, creds *remoteCredentials) (bool, error) {\n\tif creds.empty() {\n\t\treturn false, nil // no credentials to pass\n\t}\n\tif !s.serverMode {\n\t\treturn false, nil // embedded mode: withEnvCredentials works in-process\n\t}\n\tif !s.hasCLIDatabase() {\n\t\treturn false, nil\n\t}\n\tremotes, err := s.ListRemotes(ctx)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"list Dolt remotes before credential routing for peer %q: %w\", peer, err)\n\t}\n\tfor _, r := range remotes {\n\t\tif r.Name == peer {\n\t\t\tif err := s.ensureMatchingCLIRemote(peer, r.URL); err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"peer remote %q has credentials and requires CLI routing: %w\", peer, err)\n\t\t\t}\n\t\t\treturn true, nil\n\t\t}\n\t}\n\treturn false, nil\n}\n\nfunc (s *DoltStore) shouldUseCLIForPeerCredentialsWithError(ctx context.Context, peer string, creds *remoteCredentials) (bool, error) {\n\treturn s.prepareCLIRouteForPeerCredentials(ctx, peer, creds)\n}\n\n// shouldUseCLIForCredentials returns true when CLI subprocess routing should\n// be used instead of SQL path for credential-bearing push/pull operations.","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/credentials.go#L625-L661","documentation":"In server mode, before routing credential-bearing peer operations through the Dolt CLI, bd lists SQL-visible remotes to decide routing. This error wraps a ListRemotes failure during that pre-flight for a peer. The library throws it because it can't safely choose between SQL-path and CLI-path credential handling without knowing the remote set.","triggerScenarios":"prepareCLIRouteForPeerCredentials calls ListRemotes and the underlying query against the Dolt SQL server fails: server down/restarted, connection dropped, context cancelled, or database locked. Requires server mode + a CLI database + non-empty creds to even reach this point.","commonSituations":"dolt-sql-server crashed between operations; transient network failure to a remote server; long-running session whose connection timed out right before a push/pull.","solutions":["Check the dolt-sql-server is running and reachable; restart it if needed, then retry the sync.","Retry the operation — this is often transient (connection reset).","Verify the store's connection isn't stale after a server restart; reopen the store.","Check the Dolt server logs for the underlying query error to fix root cause (locks, corruption)."],"exampleFix":"// before\nok, err := shouldUseCLIForPeerCredentialsWithError(ctx, \"peer\", creds) // list Dolt remotes ... connection refused\n// after: ensure server is up, then retry\n// dolt sql-server &\nok, err := shouldUseCLIForPeerCredentialsWithError(ctx, \"peer\", creds)","handlingStrategy":"retry","validationCode":"// probe SQL connectivity before the routing pre-flight\nif err := db.PingContext(ctx); err != nil { /* restart/reconnect dolt-sql-server first */ }","typeGuard":null,"tryCatchPattern":"ok, err := shouldUseCLIForPeerCredentialsWithError(ctx, peer, creds)\nif err != nil && strings.Contains(err.Error(), \"list Dolt remotes before credential routing\") {\n    time.Sleep(2 * time.Second)\n    ok, err = shouldUseCLIForPeerCredentialsWithError(ctx, peer, creds)\n}","preventionTips":["Supervise dolt-sql-server with auto-restart","Use fresh contexts per operation, not long-lived cancelled ones","Monitor connection pool health in long-running processes","Retry transient SQL errors with exponential backoff"],"tags":["database","remotes","cli-routing","federation"],"backgroundTag":"list-remotes-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}