Skip to content

Commit

Permalink
Replace INVALID_ARGUMENT errors with INTERNAL
Browse files Browse the repository at this point in the history
- Per https://github.com/grpc/grpc/blob/9d0bc30edbe14fef58f32e74009dd513dee2cfd0/doc/statuscodes.md, INVALID_ARGUMENT should not be returned by the library
- Relevant issue: grpc#1672
  • Loading branch information
jeanbza committed Feb 16, 2018
1 parent dfa1834 commit 5d53cb8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions benchmark/worker/benchmark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error
case testpb.ClientType_SYNC_CLIENT:
case testpb.ClientType_ASYNC_CLIENT:
default:
return nil, nil, status.Errorf(codes.InvalidArgument, "unknow client type: %v", config.ClientType)
return nil, nil, status.Errorf(codes.Internal, "unknow client type: %v", config.ClientType)
}

// Check and set security options.
Expand All @@ -128,7 +128,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error
}
creds, err := credentials.NewClientTLSFromFile(*caFile, config.SecurityParams.ServerHostOverride)
if err != nil {
return nil, nil, status.Errorf(codes.InvalidArgument, "failed to create TLS credentials %v", err)
return nil, nil, status.Errorf(codes.Internal, "failed to create TLS credentials %v", err)
}
opts = append(opts, grpc.WithTransportCredentials(creds))
} else {
Expand All @@ -142,7 +142,7 @@ func createConns(config *testpb.ClientConfig) ([]*grpc.ClientConn, func(), error
opts = append(opts, grpc.WithDefaultCallOptions(grpc.CallCustomCodec(byteBufCodec{})))
case *testpb.PayloadConfig_SimpleParams:
default:
return nil, nil, status.Errorf(codes.InvalidArgument, "unknow payload config: %v", config.PayloadConfig)
return nil, nil, status.Errorf(codes.Internal, "unknow payload config: %v", config.PayloadConfig)
}
}

Expand Down Expand Up @@ -177,7 +177,7 @@ func performRPCs(config *testpb.ClientConfig, conns []*grpc.ClientConn, bc *benc
payloadRespSize = int(c.SimpleParams.RespSize)
payloadType = "protobuf"
default:
return status.Errorf(codes.InvalidArgument, "unknow payload config: %v", config.PayloadConfig)
return status.Errorf(codes.Internal, "unknow payload config: %v", config.PayloadConfig)
}
}

Expand All @@ -187,7 +187,7 @@ func performRPCs(config *testpb.ClientConfig, conns []*grpc.ClientConn, bc *benc
case *testpb.LoadParams_Poisson:
return status.Errorf(codes.Unimplemented, "unsupported load params: %v", config.LoadParams)
default:
return status.Errorf(codes.InvalidArgument, "unknown load params: %v", config.LoadParams)
return status.Errorf(codes.Internal, "unknown load params: %v", config.LoadParams)
}

rpcCountPerConn := int(config.OutstandingRpcsPerChannel)
Expand All @@ -200,7 +200,7 @@ func performRPCs(config *testpb.ClientConfig, conns []*grpc.ClientConn, bc *benc
bc.doCloseLoopStreaming(conns, rpcCountPerConn, payloadReqSize, payloadRespSize, payloadType)
// TODO open loop.
default:
return status.Errorf(codes.InvalidArgument, "unknown rpc type: %v", config.RpcType)
return status.Errorf(codes.Internal, "unknown rpc type: %v", config.RpcType)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions benchmark/worker/benchmark_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma
case testpb.ServerType_ASYNC_SERVER:
case testpb.ServerType_ASYNC_GENERIC_SERVER:
default:
return nil, status.Errorf(codes.InvalidArgument, "unknow server type: %v", config.ServerType)
return nil, status.Errorf(codes.Internal, "unknow server type: %v", config.ServerType)
}

// Set security options.
Expand Down Expand Up @@ -137,7 +137,7 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma
case *testpb.PayloadConfig_ComplexParams:
return nil, status.Errorf(codes.Unimplemented, "unsupported payload config: %v", config.PayloadConfig)
default:
return nil, status.Errorf(codes.InvalidArgument, "unknow payload config: %v", config.PayloadConfig)
return nil, status.Errorf(codes.Internal, "unknow payload config: %v", config.PayloadConfig)
}
} else {
// Start protobuf server if payload config is nil.
Expand Down
2 changes: 1 addition & 1 deletion grpclb/grpclb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (b *remoteBalancer) BalanceLoad(stream lbspb.LoadBalancer_BalanceLoadServer
}
initReq := req.GetInitialRequest()
if initReq.Name != beServerName {
return status.Errorf(codes.InvalidArgument, "invalid service name: %v", initReq.Name)
return status.Errorf(codes.Internal, "invalid service name: %v", initReq.Name)
}
resp := &lbmpb.LoadBalanceResponse{
LoadBalanceResponseType: &lbmpb.LoadBalanceResponse_InitialResponse{
Expand Down
2 changes: 1 addition & 1 deletion stress/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *server) GetGauge(ctx context.Context, in *metricspb.GaugeRequest) (*met
if g, ok := s.gauges[in.Name]; ok {
return &metricspb.GaugeResponse{Name: in.Name, Value: &metricspb.GaugeResponse_LongValue{LongValue: g.get()}}, nil
}
return nil, status.Errorf(codes.InvalidArgument, "gauge with name %s not found", in.Name)
return nil, status.Errorf(codes.Internal, "gauge with name %s not found", in.Name)
}

// createGauge creates a gauge using the given name in metrics server.
Expand Down
2 changes: 1 addition & 1 deletion transport/handler_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats sta
for _, v := range vv {
v, err := decodeMetadataHeader(k, v)
if err != nil {
return nil, streamErrorf(codes.InvalidArgument, "malformed binary metadata: %v", err)
return nil, streamErrorf(codes.Internal, "malformed binary metadata: %v", err)
}
metakv = append(metakv, k, v)
}
Expand Down
2 changes: 1 addition & 1 deletion transport/handler_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func TestHandlerTransport_HandleStreams_Unimplemented(t *testing.T) {

// Tests that codes.InvalidArgument will close the body, per comment in handler_server.go.
func TestHandlerTransport_HandleStreams_InvalidArgument(t *testing.T) {
handleStreamCloseBodyTest(t, codes.InvalidArgument, "bad arg")
handleStreamCloseBodyTest(t, codes.Internal, "bad arg")
}

func handleStreamCloseBodyTest(t *testing.T, statusCode codes.Code, msg string) {
Expand Down

0 comments on commit 5d53cb8

Please sign in to comment.