grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.51k stars 766 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 15: invalid continuation byte #1236

Open AMontagu opened 2 years ago

AMontagu commented 2 years ago

Hello

When I try to send special character in metadata like "ç" I got this error.

The stack trace is:

Traceback (most recent call last):
File "src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi", line 48, in grpc._cython.cygrpc._decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 15: invalid continuation byte

I look a bit and tryed to encode my header value with encodeUri but even is the error disapear I need to decode in the backend. I was wondering what was the best practices to avoid this error ?

PS: I use grpc-web@1.3.1

sampajano commented 1 year ago

Hi thanks for the question!

Without knowing too much about the server impl, i'd say encode/decode the metadata like you did might be a fairly decent workaround for this issue. :)

AMontagu commented 1 year ago

Hello @sampajano, Thanks for the reply.

We use Python aio grpc version 1.44. For the proxy we use istio with envoy filter.

Do not hesitate if you need further informations.

For me it look like a forgot into the grpc web protocol to correctly encode metadata. But maybe it's inside the google protobuf directly. Informations about this point could be a great start.

What grpc web send to the proxy when you put a "ç" character for example ?