Skip to content

Commit fba9d83

Browse files
committed
fix(grpc): Transform metadata into Metadata object in case it's a tuple
Up until version 1.65.0 of grpcio, the metadata was not guaranteed to arrive as the type specified in annotations but could be a tuple. To support versions before that we check and transform it here.
1 parent 6b17d04 commit fba9d83

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sentry_sdk/integrations/grpc/aio/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def _update_client_call_details_metadata_from_scope(
2323
) -> ClientCallDetails:
2424
if client_call_details.metadata is None:
2525
client_call_details = client_call_details._replace(metadata=Metadata())
26+
elif not isinstance(client_call_details.metadata, Metadata):
27+
client_call_details = client_call_details._replace(
28+
metadata=Metadata.from_tuple(client_call_details.metadata)
29+
)
2630
for key, value in Scope.get_current_scope().iter_trace_propagation_headers():
2731
client_call_details.metadata.add(key, value)
2832
return client_call_details

0 commit comments

Comments
 (0)