# Buggy code
def __init__(
    self,
    message: Union[dict, tuple] = (),
    auto: bool = False,
    harmonization: dict = None,
) -> None:
    try:
        classname = message["__type"].lower()
        del message["__type"]
    except (KeyError, TypeError):
        classname = self.__class__.__name__.lower()

    if harmonization is None:
        harmonization = utils.load_configuration(HARMONIZATION_CONF_FILE)
    try:
        self.harmonization_config = harmonization[classname]
    except KeyError:
        raise exceptions.InvalidArgument(
            "__type",
            got=classname,
            expected=VALID_MESSSAGE_TYPES,
            docs=HARMONIZATION_CONF_FILE,
        )

    if (
        classname == "event"
        and "extra" in self.harmonization_config
        and self.harmonization_config["extra"]["type"] == "JSON"
    ):
        warnings.warn(
            "Assuming harmonization type 'JSONDict' for harmonization field 'extra'. "
            "This assumption will be removed in version 3.0.",
            DeprecationWarning,
        )
        self.harmonization_config["extra"]["type"] = "JSONDict"
    for harm_key in self.harmonization_config.keys():
        if not re.match("^[a-z_](.[a-z_0-9]+)*$", harm_key) and harm_key != "__type":
            raise exceptions.InvalidKey("Harmonization key %r is invalid." % harm_key)

    super().__init__()
    if isinstance(message, dict):
        iterable = message.items()
    elif isinstance(message, tuple):
        iterable = message
    else:
        raise ValueError(
            "Type %r of message can't be handled, must be dict or tuple.", type(message)
        )
    for key, value in iterable:
        if not self.add(key, value, sanitize=False, raise_failure=False):
            self.add(key, value, sanitize=True)


# Traceback (intelmq.lib.exceptions.PipelineError)
abusix-expert-cz: Bot has found a problem.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/bot.py", line 269, in start
self.process()
File "/usr/local/lib/python3.8/dist-packages/intelmq/bots/experts/abusix/expert.py", line 26, in process
event = self.receive_message()
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/bot.py", line 606, in receive_message
self.__current_message = libmessage.MessageFactory.unserialize(message,
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/message.py", line 72, in unserialize
return MessageFactory.from_dict(message, harmonization=harmonization,
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/message.py", line 54, in from_dict
return class_reference(message, auto=True, harmonization=harmonization)
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/message.py", line 539, in __init__
super().__init__(template, auto, harmonization)
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/message.py", line 127, in __init__
self.add(key, value, sanitize=True)
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/message.py", line 249, in add
raise exceptions.InvalidValue(key, old_value)
intelmq.lib.exceptions.InvalidValue: invalid value 0 (<class 'int'>) for key 'source.asn'
abusix-expert-cz: Current Message(event): None.
abusix-expert-cz: Bot will continue in 15 seconds.
abusix-expert-cz: Pipeline failed.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/bot.py", line 269, in start
self.process()
File "/usr/local/lib/python3.8/dist-packages/intelmq/bots/experts/abusix/expert.py", line 26, in process
event = self.receive_message()
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/bot.py", line 591, in receive_message
message = self.__source_pipeline.receive()
File "/usr/local/lib/python3.8/dist-packages/intelmq/lib/pipeline.py", line 122, in receive
raise exceptions.PipelineError("There's already a message, first "
intelmq.lib.exceptions.PipelineError: pipeline failed - "There's already a message, first acknowledge the existing one."
abusix-expert-cz: Bot will continue in 15 seconds.

# Fixed code
def __init__(
    self,
    message: Union[dict, tuple] = (),
    auto: bool = False,
    harmonization: dict = None,
) -> None:
    try:
        classname = message["__type"].lower()
        del message["__type"]
    except (KeyError, TypeError):
        classname = self.__class__.__name__.lower()

    if harmonization is None:
        harmonization = utils.load_configuration(HARMONIZATION_CONF_FILE)
    try:
        self.harmonization_config = harmonization[classname]
    except KeyError:
        raise exceptions.InvalidArgument(
            "__type",
            got=classname,
            expected=VALID_MESSSAGE_TYPES,
            docs=HARMONIZATION_CONF_FILE,
        )

    if (
        classname == "event"
        and "extra" in self.harmonization_config
        and self.harmonization_config["extra"]["type"] == "JSON"
    ):
        warnings.warn(
            "Assuming harmonization type 'JSONDict' for harmonization field 'extra'. "
            "This assumption will be removed in version 3.0.",
            DeprecationWarning,
        )
        self.harmonization_config["extra"]["type"] = "JSONDict"
    for harm_key in self.harmonization_config.keys():
        if not re.match("^[a-z_](.[a-z_0-9]+)*$", harm_key) and harm_key != "__type":
            raise exceptions.InvalidKey("Harmonization key %r is invalid." % harm_key)

    super().__init__()
    if isinstance(message, dict):
        self.iterable = message
    elif isinstance(message, tuple):
        self.iterable = dict(message)
    else:
        raise ValueError(
            "Type %r of message can't be handled, must be dict or tuple.", type(message)
        )
    for key, value in self.iterable.items():
        if not self.add(key, value, sanitize=False, raise_failure=False):
            self.add(key, value, sanitize=True)