{"record":{"id":"feb1e57adfaa9899","repo":"gastownhall/beads","slug":"failed-to-push-to-peer-s-w","errorCode":null,"errorMessage":"failed to push to peer %s: %w","messagePattern":"failed to push to peer (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/federation.go","lineNumber":58,"sourceCode":"// pushRefToPeer pushes a specific refspec to a peer remote. The refspec can be\n// a simple branch name (\"main\") or a mapping (\"staging:main\").\nfunc (s *DoltStore) pushRefToPeer(ctx context.Context, peer string, refspec string) error {\n\tif useCLI, err := s.prepareCLIRouteForPeerGitProtocol(ctx, peer); err != nil {\n\t\treturn err\n\t} else if useCLI {\n\t\treturn s.withPeerCredentials(ctx, peer, func(creds *remoteCredentials) error {\n\t\t\treturn s.doltCLIPushRefToPeer(ctx, peer, refspec, creds)\n\t\t})\n\t}\n\treturn s.withPeerCredentials(ctx, peer, func(creds *remoteCredentials) error {\n\t\tif useCLI, err := s.prepareCLIRouteForPeerCredentials(ctx, peer, creds); err != nil {\n\t\t\treturn err\n\t\t} else if useCLI {\n\t\t\treturn s.doltCLIPushRefToPeer(ctx, peer, refspec, creds)\n\t\t}\n\t\treturn withEnvCredentials(creds, func() error {\n\t\t\tif err := s.execWithLongTimeout(ctx, \"CALL DOLT_PUSH(?, ?)\", peer, refspec); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to push to peer %s: %w\", peer, err)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t})\n}\n\n// PullFrom pulls changes from a specific peer remote.\n// If credentials are stored for this peer, they are used automatically.\n// For git-protocol remotes, uses CLI `dolt pull` to avoid MySQL connection timeouts.\n// Returns any merge conflicts if present.\nfunc (s *DoltStore) PullFrom(ctx context.Context, peer string) ([]storage.Conflict, error) {\n\tvar conflicts []storage.Conflict\n\terr := s.withCircuitWrite(ctx, func(ctx context.Context) error {\n\t\tvar err error\n\t\tconflicts, err = s.pullFromPeer(ctx, peer)\n\t\treturn err\n\t})\n\treturn conflicts, err","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/federation.go#L40-L76","documentation":"Federation push to a peer failed: the CALL DOLT_PUSH('<peer>', '<refspec>') stored procedure returned an error. Causes include the peer not being configured as a Dolt remote, authentication/credential failure, the refspec not existing locally, or network failure reaching the peer. The peer name and underlying error are wrapped for diagnosis.","triggerScenarios":"pushRefToPeer with the SQL path (non-CLI) calling execWithLongTimeout('CALL DOLT_PUSH(?, ?)', peer, refspec) when the peer remote is missing from config, credentials are rejected, the branch/ref doesn't exist, or the peer is unreachable.","commonSituations":"Federation peer renamed or removed but still referenced in config; SSH/HTTPS credentials expired; pushing a branch that was deleted locally; peer's Dolt server offline or firewall blocking the port; mixing CLI and SQL push paths with different credential setups.","solutions":["Verify the peer is a configured Dolt remote (`dolt remote -v`) and the name matches your federation config.","Re-authenticate or refresh credentials (withEnvCredentials path) — check tokens/SSH keys haven't expired.","Confirm the refspec exists locally (`dolt branch`) and on the expected ref; create or re-fetch it if missing.","Test connectivity to the peer (curl/ssh the peer's endpoint); if the SQL path keeps failing, retry via the CLI path (dolt push) which gives clearer errors."],"exampleFix":"// before: pushing an unconfigured peer\ns.execWithLongTimeout(ctx, \"CALL DOLT_PUSH(?, ?)\", \"staging\", refspec)\n// fatal: unknown remote 'staging'\n// after: add the peer remote first\ndolt remote add staging https://doltremoteapi.dolthub.com/org/staging-db\n// then retry the push","handlingStrategy":"validation","validationCode":"// Shell: verify peer remote and local ref exist before pushing\ndolt remote -v | grep -q \"^peer\" || { echo \"peer remote not configured\"; exit 1; }\ndolt rev-parse --verify <refspec> || { echo \"refspec missing locally\"; exit 1; }","typeGuard":"func IsPushToPeerError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to push to peer\")\n}","tryCatchPattern":"err := federation.PushToPeer(ctx, peer, refspec, creds)\nif err != nil && strings.Contains(err.Error(), \"failed to push to peer \"+peer) {\n\t// fall back to CLI push which yields clearer auth errors\n\treturn federation.PushToPeerViaCLI(ctx, peer, refspec, creds)\n}","preventionTips":["Keep federation peer remotes in config in sync with actual peers; remove stale entries.","Rotate/refresh credentials before expiry; test auth with a lightweight remote call.","Ensure the refspec exists locally before scheduling pushes.","Monitor peer reachability (health checks) so network failures are caught before sync windows."],"tags":["dolt","federation","push","network","remote"],"backgroundTag":"git-push-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}