def fix_datagrepper_message(message):
    """
    See if a message is (probably) a datagrepper message and attempt to mutate
    it to pass signature validation.

    Datagrepper adds the 'source_name' and 'source_version' keys. If messages happen
    to use those keys, they will fail message validation. Additionally, a 'headers'
    dictionary is present on all responses, regardless of whether it was in the
    original message or not. This is deleted if it's null, which won't be correct in
    all cases. Finally, datagrepper turns the 'timestamp' field into a float, but it
    might have been an integer when the message was signed.

    A copy of the dictionary is made and returned if altering the message is necessary.

    I'm so sorry.

    Args:
        message (dict): A message to clean up.

    Returns:
        dict: A copy of the provided message, with the datagrepper-related keys removed
            if they were present.
    """
    if not ('source_name' in message and 'source_version' in message):
        return message
    message = message.copy()
    del message['source_name']
    del message['source_version']
    if 'headers' in message and not message['headers']:
        del message['headers']
    if 'timestamp' in message:
        message['timestamp'] = int(message['timestamp'])
    return message
