Skip to content

Commit

Permalink
grpc-client: Do not crash on empty response
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Busse <bj.rn@baerlin.eu>
  • Loading branch information
bbusse committed Jul 9, 2022
1 parent f49e7bc commit 922bd11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/grpc-client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func createPassword(cli api.DexClient) error {

// Create password.
if resp, err := cli.CreatePassword(context.TODO(), createReq); err != nil || resp.AlreadyExists {
if resp.AlreadyExists {
if resp != nil && resp.AlreadyExists {
return fmt.Errorf("Password %s already exists", createReq.Password.Email)
}
return fmt.Errorf("failed to create password: %v", err)
Expand Down Expand Up @@ -115,7 +115,7 @@ func createPassword(cli api.DexClient) error {

// Delete password with email = test@example.com.
if resp, err := cli.DeletePassword(context.TODO(), deleteReq); err != nil || resp.NotFound {
if resp.NotFound {
if resp != nil && resp.NotFound {
return fmt.Errorf("Password %s not found", deleteReq.Email)
}
return fmt.Errorf("failed to delete password: %v", err)
Expand Down

0 comments on commit 922bd11

Please sign in to comment.