diff --git a/pathfinderevents.py b/pathfinderevents.py index b91d024..64ffdec 100644 --- a/pathfinderevents.py +++ b/pathfinderevents.py @@ -179,11 +179,14 @@ def _key_mapper(ce: CloudEvent) -> Any | None: # noqa: ANN401 ce, key_mapper=_key_mapper, ) + headers: list[tuple[str, bytes]] | None + if kafka_msg.headers: + headers = list(kafka_msg.headers.items()) self.producer.send( self.topic, key=kafka_msg.key, value=kafka_msg.value, - headers=kafka_msg.headers if kafka_msg.headers else None, + headers=headers, ).add_errback(on_send_error) self.producer.flush() logger.info( diff --git a/tests/test_pathfinderevents.py b/tests/test_pathfinderevents.py index fa2f32b..ceea6b9 100644 --- a/tests/test_pathfinderevents.py +++ b/tests/test_pathfinderevents.py @@ -106,7 +106,7 @@ def test_api_webhook(mock_producer, mock_api, mock_sys_exit): # noqa: ARG001 "test", key="ch.rabe.api.events.pathfinder.v0alpha1.OnAir.Klangbecken", value=ANY, - headers={"content-type": b"text/plain"}, + headers=[("content-type", b"text/plain")], ) value = json.loads(mock_producer.send.call_args.kwargs["value"]) assert value["data"] == "Klangbecken"