def _log_locations_json_sanity_check(self, data):
        """Check the sanity of the user log locations json.

        This json can have anything in it. Just make sure it is a valid json,
        and it has all the fields we need. Also check that it's not too big and
        the number of logfiles is decent.
        """
        max_data_len = 1e6  # one MB looks excesive
        max_files = 100  # more than 100 log files to link is excessive

        if len(data) > max_data_len:
            raise KeyError('The file list is too large.')

        if 'log_files' not in data:
            raise KeyError('log_files key missing.')

        if len(data.keys()) > 1:
            raise KeyError('The only valid key is log_files.')

        log_files = data['log_files']

        if len(log_files) > max_files:
            raise KeyError('Too many log files (> 1000).')

        for log in log_files:
            if 'name' not in log.keys():
                raise KeyError('Missing the name key.')

            if len(log.keys()) > 2:
                raise KeyError('Too many keys in the log tuple.')

            if len(log.keys()) > 1 and 'type' not in log.keys():
                raise KeyError('Only other valid key is type.')

            if not isinstance(log['name'], str):
                raise KeyError('name value is not a string.')

            if 'type' in log and not isinstance(log['type'], str):
                raise KeyError('type value is not a string.')
dataset/ETHPy150Open cloudviz/agentless-system-crawler/crawler/dockercontainer.py/DockerContainer._log_locations_json_sanity_check/original