From 28eddcced0c68d5f8c1f3c83edafb20a9aedd5ad Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Wed, 15 Nov 2023 23:24:44 +0100 Subject: [PATCH] fix: ssh stdout and stderr are empty --- connection/ssh.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/connection/ssh.go b/connection/ssh.go index 88a4a10..ed79bd5 100644 --- a/connection/ssh.go +++ b/connection/ssh.go @@ -95,14 +95,19 @@ func (c *Connection) runSSH(ctx context.Context, cmd string) (string, string, er } // Return the error if stderr has no value - if err != nil && stderrBytes == nil { + if err != nil && len(stderrBytes) == 0 { return "", "", err } // Return stderr over the error when stderr has a value - if stderrBytes != nil { + if len(stderrBytes) > 0 { return "", string(stderrBytes), nil } + // Return error when stdout and stderr have no values + if len(stdoutBytes) == 0 && len(stderrBytes) == 0 { + return "", "", winerror.Errorf(winerror.WindowsError, "ssh session: stdout and stderr are empty") + } + return string(stdoutBytes), "", nil }