def get_handler_name(message):
    """
    Looks at a message, checks it has a sensible type, and returns the
    handler name for that type.
    """
    if 'type' not in message:
        raise ValueError("Incoming message has no 'type' attribute")
    if message['type'].startswith('_'):
        raise ValueError('Malformed type in message (leading underscore)')
    return message['type'].replace('.', '_')
