From 88372b2fa162fc9fed6295344309ce89b1312257 Mon Sep 17 00:00:00 2001 From: Alec Merdler Date: Fri, 22 Mar 2024 15:24:10 -0400 Subject: [PATCH] Fix panic on permission check error Ensures that we nil check the response from a CheckPermission request before attempting to extract the debug info from it. This regression was introduced in #354 where we added support for the new debug info in the response body rather than in HTTP trailers. --- internal/commands/permission.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/commands/permission.go b/internal/commands/permission.go index e8d6c912..bb1938f3 100644 --- a/internal/commands/permission.go +++ b/internal/commands/permission.go @@ -206,7 +206,12 @@ func checkCmdFunc(cmd *cobra.Command, args []string) error { var trailerMD metadata.MD resp, err := client.CheckPermission(ctx, request, grpc.Trailer(&trailerMD)) if err != nil { - derr := displayDebugInformationIfRequested(cmd, resp.DebugTrace, trailerMD, true) + var debugInfo *v1.DebugInformation + if resp != nil { + debugInfo = resp.DebugTrace + } + + derr := displayDebugInformationIfRequested(cmd, debugInfo, trailerMD, true) if derr != nil { return derr }