def decode_to_utf8(text) -> bytes:  # pragma: no cover
    """
    Paramiko returns bytes object and we need to ensure it is utf-8 before parsing.

    :param text: non-decoded bytes
    :return: decoded text
    """
    try:
        return text.decode("utf-8")
    except (AttributeError, UnicodeEncodeError):
        return text