From e5395a42c603f95f5c3f75c0fc04c82833b9ba84 Mon Sep 17 00:00:00 2001 From: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:45:03 +0000 Subject: [PATCH] fix(sync): keep the pull/push step when explaining an SSH dial timeout (bd-fzes0) syncFailureText rewrites an SSH dial timeout into "SSH remote could not be reached (dial timed out): " so Dolt's ssh-add / credential hints stop pointing operators at auth. It returned only that rewrite, which also dropped runSyncLoop's "pull: " / "push: " wrap, and that step is how an operator tells whether local work already reached the remote. Keep the error's outermost wrap segment (err.Error() minus errors.Unwrap(err).Error()) in front of the explanation, scrubbed like the line. A segment that itself contains the dial line is git output folded into the wrap (cliTransferError's "dolt push failed: : %w"), not a step, so it is dropped rather than echoing the hints. Unwrapped errors keep today's text. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 --- cmd/bd/sync.go | 19 ++++++++++++++++++- cmd/bd/sync_test.go | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index bd2c97311..6eff49c95 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -915,11 +915,28 @@ func syncFailureText(err error) string { return "" } if line := sshDialTimeoutLine.FindString(err.Error()); line != "" { - return "SSH remote could not be reached (dial timed out): " + scrubURLCredentials(strings.TrimSpace(line)) + return syncFailureStep(err, line) + "SSH remote could not be reached (dial timed out): " + scrubURLCredentials(strings.TrimSpace(line)) } return err.Error() } +// syncFailureStep returns err's outermost wrap segment for the dial-timeout +// rewrite to keep: runSyncLoop's "pull: " or "push: " step, which is how an +// operator tells whether local work already reached the remote. A segment +// that contains the dial line is git output folded into the wrap +// (cliTransferError), auth hints and all, so it yields "" instead. +func syncFailureStep(err error, line string) string { + inner := errors.Unwrap(err) + if inner == nil { + return "" + } + prefix, ok := strings.CutSuffix(err.Error(), inner.Error()) + if !ok || strings.Contains(prefix, line) { + return "" + } + return scrubURLCredentials(prefix) +} + // mergeBlockersOp builds the loop's positive constraint-violation hook, or nil // when this store cannot answer the question — an unimplemented interface // must leave the detector silent, never guessing. Bound to the same st the diff --git a/cmd/bd/sync_test.go b/cmd/bd/sync_test.go index 1acd6ff9d..f8e57bd2c 100644 --- a/cmd/bd/sync_test.go +++ b/cmd/bd/sync_test.go @@ -34,6 +34,25 @@ func TestSyncFailureTextDistinguishesSSHDialTimeoutFromAuth(t *testing.T) { t.Errorf("dial timeout retained auth hint %q: %q", misleading, got) } } + // The rewrite must keep runSyncLoop's step: pull vs push is what tells an + // operator whether local work already reached the remote. A wrap segment + // that itself embeds git's output (cliTransferError's shape) is not a step + // and must not come back, auth hints and all. + explained := "SSH remote could not be reached (dial timed out): " + timeoutLine + cliTransfer := fmt.Errorf("dolt push failed: %s: %w", gitText, errors.New("exit status 1")) + for _, tc := range []struct { + name string + err error + want string + }{ + {"pull step", timeout, "pull: " + explained}, + {"push step over a CLI transfer", fmt.Errorf("push: %w", cliTransfer), "push: " + explained}, + {"bare CLI transfer", cliTransfer, explained}, + } { + if got := syncFailureText(tc.err); got != tc.want { + t.Errorf("%s: got %q, want %q", tc.name, got, tc.want) + } + } auth := fmt.Errorf("pull: %w", errors.New("git@host: Permission denied (publickey).\nhint: run `ssh-add ` to pre-load your key for SSH remotes")) if got := syncFailureText(auth); got != auth.Error() {