from typing import Tuple
from typing import Union


def is_secret_key(key: str) -> Tuple[bool, Union[str, None]]:
    """Check if the Airflow Flask webserver secret key is valid.
    :param key: Key to check.
    :return: Validity, and an error message if not valid.
    """

    key_bytes = bytes(key, "utf-8")
    message = None

    key_length = len(key_bytes)
    if key_length < 16:
        message = f"Secret key should be length >=16, but is length {key_length}."
        return False, message

    return True, message