code: def test_using_grpc_context_bad_function_signature(
      ray_instance, ray_shutdown, streaming: bool, issue: str
  ):
      """Test using gRPC context with bad function signature.
  
      When the deployment sets code, details, and trailing metadata in the gRPC context,
      the response will reflect those values.
      """
      grpc_port = 9000
      grpc_servicer_functions = [
          "ray.serve.generated.serve_pb2_grpc.add_UserDefinedServiceServicer_to_server",
      ]
  
      serve.start(
          grpc_options=gRPCOptions(
              port=grpc_port,
              grpc_servicer_functions=grpc_servicer_functions,
          ),
      )
      error_code = grpc.StatusCode.DATA_LOSS
      error_message = "my specific error message"
      trailing_metadata = ("foo", "bar")
  
      if issue == "incorrect_spelling":
  
          @serve.deployment()
          class HelloModel:
              def __call__(
                  self,
                  user_message: serve_pb2.UserDefinedMessage,
                  grpc_context_incorrect_spelling: RayServegRPCContext,
              ):
                  grpc_context_incorrect_spelling.set_code(error_code)
                  grpc_context_incorrect_spelling.set_details(
                      error_message
                  )
                  grpc_context_incorrect_spelling.set_trailing_metadata(
                      [trailing_metadata]
                  )
                  return serve_pb2.UserDefinedResponse(greeting="hello")
  
              def Streaming(
                  self,
                  user_message: serve_pb2.UserDefinedMessage,
                  grpc_context_incorrect_spelling: RayServegRPCContext,
              ):
                  grpc_context_incorrect_spelling.set_code(error_code)
                  grpc_context_incorrect_spelling.set_details(
                      error_message
                  )
                  grpc_context_incorrect_spelling.set_trailing_metadata(
                      [trailing_metadata]
                  )
                  yield serve_pb2.UserDefinedResponse(greeting="hello")
  
      elif issue == "more_args":
  
          @serve.deployment()
          class HelloModel:
              def __call__(
                  self,
                  user_message: serve_pb2.UserDefinedMessage,
                  grpc_context: RayServegRPCContext,
                  extra_required_arg: Any,
              ):
                  grpc_context.set_code(error_code)
                  grpc_context.set_details(error_message)
                  grpc_context.set_trailing_metadata(
                      [trailing_metadata]
                  )
                  return serve_pb2.UserDefinedResponse(greeting="hello")
  
              def Streaming(
                  self,
                  user_message: serve_pb2.UserDefinedMessage,
                  grpc_context: RayServegRPCContext,
                  extra_required_arg: Any,
              ):
                  grpc_context.set_code(error_code)
                  grpc_context.set_details(error_message)
                  grpc_context.set_trailing_metadata(
                      [trailing_metadata]
                  )
                  yield serve_pb2.UserDefinedResponse(greeting="hello")
  
      model = HelloModel.bind()
      app_name = "app1"
      serve.run(target=model, name=app_name)
  
      channel = grpc.insecure_channel("localhost:9000")
      stub = serve_pb2_grpc.UserDefinedServiceStub(channel)
      request = serve_pb2.UserDefinedMessage(
          name="foo", num=30, foo="bar"
      )
  
      with pytest.raises(grpc.RpcError) as exception_info:
          if streaming:
              list(stub.Streaming(request=request))
          else:
              _ = stub.__call__(request=request)
      rpc_error = exception_info.value
  
      assert rpc_error.code() == grpc.StatusCode.INTERNAL
      assert (
          "missing 1 required positional argument:"
          in rpc_error.details()
      )
      if issue == "incorrect_spelling":
          assert (
              "grpc_context_incorrect_spelling" in rpc_error.details()
          )
      elif issue == "more_args":
          assert "extra_required_arg" in rpc_error.details()
  
imports: import os
  import sys
  from typing import Any
  import grpc
  import pytest
  import ray
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.cluster_utils import Cluster
  from ray.serve._private.common import DeploymentID
  from ray.serve._private.constants import SERVE_NAMESPACE
  from ray.serve._private.test_utils import ping_fruit_stand, ping_grpc_another_method, ping_grpc_call_method, ping_grpc_healthz, ping_grpc_list_applications, ping_grpc_model_multiplexing, ping_grpc_streaming, send_signal_on_cancellation
  from ray.serve.config import gRPCOptions
  from ray.serve.generated import serve_pb2, serve_pb2_grpc
  from ray.serve.grpc_util import RayServegRPCContext
  from ray.serve.tests.test_config_files.grpc_deployment import g, g2
label_desc: Use image node_id 10 for calling a global function with example usage: test_using_grpc_context_bad_function_signature(ray_instance, ray_shutdown, streaming, issue) and returns: serve_pb2, serve_pb2