Skip to content

Exception calling application: '_Context' object has no attribute 'encode' #33364

@abruyat

Description

@abruyat

Issue description
When calling my server for a type of message, I got the following error: Exception calling application: '_Context' object has no attribute 'encode'.

This error happened right after the server received the call. The service is able to validate the format of the message (if I pass a wrong format, I will receive the correct error)

My other services are working smoothly.

My server is defined as following:

       Settings.load_settings()
        server = grpc.server(
            futures.ThreadPoolExecutor(max_workers=int(os.getenv("WORKER_NB")))
        )

        Compiler(server).compile_controllers()
        SQLProvider()

        # Add Health checking:
        health_pb2_grpc.add_HealthServicer_to_server(health.HealthServicer(), server)

        # Start the server:
        server.add_insecure_port("[::]:{}".format(os.getenv("API_PORT")))
        server.start()
        logger.info("Server started")
        server.wait_for_termination()

The main difference I can find in the call is that the protobuf message contains timestamps and enums. Is there an option to pass to the server ?

The proto message I am trying to pass looks like that:

syntax = "proto3";
import "google/protobuf/timestamp.proto";

enum En {
  A = 0;
  B = 1;
  C = 2;
}

message ComputeRequest {
    int32 a = 2;
    google.protobuf.Timestamp start_date = 3;
    repeated int32 ids = 7;
    En en = 11;
}

message ComputeResponse {
  float a = 1;
  float b = 2;
}

service ComputeService {
    rpc GetComputeResponse (ComputeRequest) returns (ComputeResponse) {}
}

Does on of you have any idea about how I can fix this issue ?

grpc version: 1.54.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions