From 0da78ce764df60d68c315f90e269d8ed615e9444 Mon Sep 17 00:00:00 2001 From: Kevin Shi Date: Wed, 15 Oct 2025 15:53:41 -0700 Subject: [PATCH 1/4] Added client version output when --debug flag is added to tsh commands --- tool/tsh/common/tsh.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index 43db25283b23a..82a7dc2c1fb79 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -1624,6 +1624,12 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { defer runtimetrace.Stop() } + // print tsh version when --debug flag is set + // to diagnose potential client version mismatch + if cf.Debug && command != ver.FullCommand() { + modules.GetModules().PrintVersion() + } + switch command { case ver.FullCommand(): err = onVersion(&cf) From 1a269fd0df3b58e7752231ac0fbc8877c8921dc8 Mon Sep 17 00:00:00 2001 From: Kevin Shi Date: Thu, 16 Oct 2025 17:09:01 -0700 Subject: [PATCH 2/4] Moved client version output to logger --- tool/tsh/common/tsh.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index 82a7dc2c1fb79..064ea1fc12edd 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -1627,7 +1627,13 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { // print tsh version when --debug flag is set // to diagnose potential client version mismatch if cf.Debug && command != ver.FullCommand() { - modules.GetModules().PrintVersion() + logger.InfoContext(ctx, "Debugging tsh client", + "version", slog.GroupValue( + slog.String("teleport", teleport.Version), + slog.String("teleport_git", teleport.Gitref), + slog.String("go", runtime.Version()), + ), + ) } switch command { From 83de4ce9c43bc88a541c37f20dc6c3014dfc17d5 Mon Sep 17 00:00:00 2001 From: Kevin Shi Date: Fri, 17 Oct 2025 11:44:46 -0700 Subject: [PATCH 3/4] Altered tsh client version output to match tbot's, added test coverage --- tool/tsh/common/tsh.go | 2 +- tool/tsh/common/tsh_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index 064ea1fc12edd..e8b3544d633f4 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -1627,7 +1627,7 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { // print tsh version when --debug flag is set // to diagnose potential client version mismatch if cf.Debug && command != ver.FullCommand() { - logger.InfoContext(ctx, "Debugging tsh client", + logger.InfoContext(ctx, "Initializing tsh", "version", slog.GroupValue( slog.String("teleport", teleport.Version), slog.String("teleport_git", teleport.Gitref), diff --git a/tool/tsh/common/tsh_test.go b/tool/tsh/common/tsh_test.go index ba62e1754b775..0e7f385552999 100644 --- a/tool/tsh/common/tsh_test.go +++ b/tool/tsh/common/tsh_test.go @@ -7710,3 +7710,13 @@ func Test_humanFriendlyValidUntilDuration(t *testing.T) { }) } } + +func TestDebugVersionOutput(t *testing.T) { + t.Setenv(tshBinMainTestEnv, "1") + testExecutable, err := os.Executable() + require.NoError(t, err) + + output, err := exec.Command(testExecutable, "logout", "--debug").CombinedOutput() + require.NoError(t, err) + require.Contains(t, string(output), "Initializing tsh version") +} From ea1f65029719686ffa09da297849f8d8484a68b2 Mon Sep 17 00:00:00 2001 From: Kevin Shi Date: Fri, 17 Oct 2025 13:45:00 -0700 Subject: [PATCH 4/4] Updated test to check versions in output --- tool/tsh/common/tsh_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tool/tsh/common/tsh_test.go b/tool/tsh/common/tsh_test.go index 0e7f385552999..f5afc09948ef1 100644 --- a/tool/tsh/common/tsh_test.go +++ b/tool/tsh/common/tsh_test.go @@ -7718,5 +7718,15 @@ func TestDebugVersionOutput(t *testing.T) { output, err := exec.Command(testExecutable, "logout", "--debug").CombinedOutput() require.NoError(t, err) + + vers := []string{ + teleport.Version, + teleport.Gitref, + runtime.Version(), + } + require.Contains(t, string(output), "Initializing tsh version") + for _, v := range vers { + require.Contains(t, string(output), v) + } }