From ac2dcce20f27cb01c85fdec44b699716e7cfd929 Mon Sep 17 00:00:00 2001 From: joerger Date: Thu, 16 Jun 2022 15:05:08 -0700 Subject: [PATCH 1/2] Properly check is not found error. --- lib/client/api.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/client/api.go b/lib/client/api.go index 6bc173b3b11b9..9ef0c91c0e5fa 100644 --- a/lib/client/api.go +++ b/lib/client/api.go @@ -1946,7 +1946,6 @@ func (tc *TeleportClient) Join(ctx context.Context, mode types.SessionParticipan if sessionID.Check() != nil { return trace.Errorf("Invalid session ID format: %s", string(sessionID)) } - notFoundErrorMessage := fmt.Sprintf("session '%s' not found or it has ended", sessionID) // connect to proxy: if !tc.Config.ProxySpecified() { @@ -1963,14 +1962,13 @@ func (tc *TeleportClient) Join(ctx context.Context, mode types.SessionParticipan } session, err := site.GetSessionTracker(ctx, string(sessionID)) - if err != nil && !trace.IsNotFound(err) { + if err != nil { + if trace.IsNotFound(err) { + return trace.NotFound("session %q not found or it has ended", sessionID) + } return trace.Wrap(err) } - if session == nil { - return trace.NotFound(notFoundErrorMessage) - } - // connect to server: nc, err := proxyClient.ConnectToNode(ctx, NodeAddr{ Addr: session.GetAddress() + ":0", From 3467e071e7779522fbdabf814c05a73e805f22e8 Mon Sep 17 00:00:00 2001 From: joerger Date: Thu, 23 Jun 2022 09:48:44 -0700 Subject: [PATCH 2/2] Return nil explicitly. --- api/client/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/client/client.go b/api/client/client.go index 295d5320282ef..53fb3f9c3db77 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -2684,7 +2684,10 @@ func (c *Client) CreateSessionTracker(ctx context.Context, st types.SessionTrack func (c *Client) GetSessionTracker(ctx context.Context, sessionID string) (types.SessionTracker, error) { req := &proto.GetSessionTrackerRequest{SessionID: sessionID} resp, err := c.grpc.GetSessionTracker(ctx, req, c.callOpts...) - return resp, trail.FromGRPC(err) + if err != nil { + return nil, trail.FromGRPC(err) + } + return resp, nil } // GetActiveSessionTrackers returns a list of active session trackers.