mrk-andreev commented on code in PR #44307: URL: https://github.com/apache/airflow/pull/44307#discussion_r1855520707
########## providers/src/airflow/providers/apache/kafka/hooks/consume.py: ########## @@ -23,6 +23,18 @@ from airflow.providers.apache.kafka.hooks.base import KafkaBaseHook +class KafkaAuthenticationError(Exception): + """Custom exception for Kafka authentication failures.""" + + pass + + +def error_callback(err): Review Comment: Looks promising! > `error_cb(kafka.KafkaError)`: Callback for generic/global error events We have to filter only related one ( https://docs.confluent.io/platform/current/clients/confluent-kafka-python/html/index.html#pythonclient-kafkaerror ). ########## providers/src/airflow/providers/apache/kafka/hooks/consume.py: ########## @@ -36,6 +48,7 @@ def __init__(self, topics: Sequence[str], kafka_config_id=KafkaBaseHook.default_ self.topics = topics def _get_client(self, config) -> Consumer: + config["error_cb"] = error_callback Review Comment: It might not be the best practice to update user-provided data. As an alternative, we could create a shallow copy instead. Additionally, we can assume that the user has already provided an error_cb. In this case, we need to decide how to handle this behavior, which is an open question. One possible solution is to call the user-defined error_cb first and then invoke our custom implementation if the user does not raise an exception. This approach makes sense because authentication errors are not recoverable, so they should interrupt execution. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
