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): <line>" 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: <output>: %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 <noreply@anthropic.com>
This commit is contained in:
parent
169c5fc499
commit
e5395a42c6
2 changed files with 37 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <key>` to pre-load your key for SSH remotes"))
|
||||
if got := syncFailureText(auth); got != auth.Error() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue