Chromium Code Reviews| Index: tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go |
| diff --git a/tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go b/tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go |
| index a4b20b52cf3d228d73e5870e83b2a2443245c121..cf873bc12b57d337c7669626a93a944268cadfe3 100644 |
| --- a/tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go |
| +++ b/tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go |
| @@ -140,8 +140,19 @@ func (r *MintMachineTokenRPC) MintMachineToken(c context.Context, req *minter.Mi |
| switch tokenReq.TokenType { |
| case tokenserver.MachineTokenType_LUCI_MACHINE_TOKEN: |
| resp, body, err := r.mintLuciMachineToken(c, args) |
| - if err != nil { |
| + switch { |
| + case err != nil: // grpc-level error |
| return nil, err |
| + case resp == nil: // should not happen |
| + panic("both resp and err can't be nil") |
| + case resp.ErrorCode != 0: // logic-level error |
|
Vadim Sh.
2017/06/20 03:49:50
this is the actual fix: don't try to log the token
|
| + if resp.TokenResponse != nil { |
| + panic("TokenResponse must be nil if ErrorCode != 0") |
| + } |
| + return resp, nil |
| + } |
| + if resp.TokenResponse == nil { |
| + panic("TokenResponse must not be nil if ErrorCode == 0") |
| } |
| if r.LogToken != nil { |
| // Errors during logging are considered not fatal. bqlog library has |