Closed arash-d closed 4 months ago
Hey @arash-d,
Thanks for highlighting this issue. Do you have any suggestions on how to address this error? Also, I'm unsure about how Kafka handles this scenario. Your contribution would be greatly appreciated.
Hey @alm0ra! Sorry for the late reply!
Actually you have 3 options:
return super().__getitem__(key, None)
return None
, something like logging.warning(f"Key '{key}' not found in CustomDict")
Based on your explanation about Kafka handling in this case and my little knowledge about your project, it seems the third option is more suitable.
Cheers!
Hey @arash-d
Thanks for suggesting solutions.
I'd be happy if you contribute by opening pull request if you have time. :) i prefer third way too.
The
CustomDict
class overrides the__getitem__
method to suppressKeyError
exceptions and returnNone
if a key is not found. While this may be intentional, it could potentially mask errors in the code. It's essential to handle errors appropriately and provide meaningful feedback to users.https://github.com/alm0ra/mockafka-py/blob/2eb4b515775882133e029a7c959f3c1c94103037/mockafka/cluster_metadata.py#L47