Skip to content

Commit

Permalink
Merge pull request #10634 from RasaHQ/fix_kafka_headers
Browse files Browse the repository at this point in the history
Only add rasa_environment header to kafka message if it is set
  • Loading branch information
indam23 authored Jan 6, 2022
2 parents f00148b + 33ea59a commit fb0cb86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/10634.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `RASA_ENVIRONMENT` header in Kafka only if the environmental variable is set.
14 changes: 8 additions & 6 deletions rasa/core/brokers/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ def _publish(self, event: Dict[Text, Any]) -> None:
else:
partition_key = None

headers = [
(
"RASA_ENVIRONMENT",
bytes(self.rasa_environment, encoding=DEFAULT_ENCODING),
)
]
headers = []
if self.rasa_environment:
headers = [
(
"RASA_ENVIRONMENT",
bytes(self.rasa_environment, encoding=DEFAULT_ENCODING),
)
]

logger.debug(
f"Calling kafka send({self.topic}, value={event},"
Expand Down

0 comments on commit fb0cb86

Please sign in to comment.