gurudesh/pytracebugs huggingface dataset:
# Buggy code
def cumsum(self, axis=None, skipna=True, *args, **kwargs):
    """Perform a cumulative sum across the DataFrame.

    Args:
        axis (int): The axis to take sum on.
        skipna (bool): True to skip NA values, false otherwise.

    Returns:
        The cumulative sum of the DataFrame.
    """
    axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
    return DataFrame(
        data_manager=self._data_manager.cumsum(axis=axis, skipna=skipna, **kwargs)
    )


# Traceback (TypeError)
RayGetError: Could not get objectid ObjectID(01000000f0cc325805f5c83895ed0532827d52de). It was created by remote function modin.data_management.partitioning.axis_partition.deploy_ray_axis_func which failed with:

Remote function modin.data_management.partitioning.axis_partition.deploy_ray_axis_func failed with:

Traceback (most recent call last):
File "/Users/William/Documents/modin/modin/data_management/partitioning/axis_partition.py", line 188, in deploy_ray_axis_func
result = func(dataframe, **kwargs)
File "/Users/William/Documents/modin/modin/data_management/data_manager.py", line 158, in helper
def helper(df, internal_indices=[]):
File "/Users/William/Documents/modin/venv/lib/python3.6/site-packages/pandas/core/generic.py", line 9661, in cum_func
result = accum_func(y, axis)
File "/Users/William/Documents/modin/venv/lib/python3.6/site-packages/pandas/core/generic.py", line 8829, in <lambda>
lambda y, axis: np.maximum.accumulate(y, axis), "max",
File "pandas/_libs/tslibs/timestamps.pyx", line 170, in pandas._libs.tslibs.timestamps._Timestamp.__richcmp__
TypeError: Cannot compare type 'Timestamp' with type 'float'

# Fixed code
def cumsum(self, axis=None, skipna=True, *args, **kwargs):
    """Perform a cumulative sum across the DataFrame.

    Args:
        axis (int): The axis to take sum on.
        skipna (bool): True to skip NA values, false otherwise.

    Returns:
        The cumulative sum of the DataFrame.
    """
    axis = pandas.DataFrame()._get_axis_number(axis) if axis is not None else 0
    self._validate_dtypes(numeric_only=True)
    return DataFrame(
        data_manager=self._data_manager.cumsum(axis=axis, skipna=skipna, **kwargs)
    )
# Buggy code
def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return the content of a snippet.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The snippet content
    """
    path = "/snippets/%s/raw" % self.get_id()
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return the content of a snippet.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The snippet content
    """
    path = "/snippets/%s/raw" % self.get_id()
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def artifacts(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get the job artifacts.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The artifacts if `streamed` is False, None otherwise.
    """
    path = "%s/%s/artifacts" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def artifacts(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get the job artifacts.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The artifacts if `streamed` is False, None otherwise.
    """
    path = "%s/%s/artifacts" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def artifact(self, path, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get a single artifact file from within the job's artifacts archive.

    Args:
        path (str): Path of the artifact
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The artifacts if `streamed` is False, None otherwise.
    """
    path = "%s/%s/artifacts/%s" % (self.manager.path, self.get_id(), path)
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def artifact(self, path, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get a single artifact file from within the job's artifacts archive.

    Args:
        path (str): Path of the artifact
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The artifacts if `streamed` is False, None otherwise.
    """
    path = "%s/%s/artifacts/%s" % (self.manager.path, self.get_id(), path)
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get the job trace.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The trace
    """
    path = "%s/%s/trace" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Get the job trace.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the artifacts could not be retrieved

    Returns:
        str: The trace
    """
    path = "%s/%s/trace" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return the content of a snippet.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The snippet content
    """
    path = "%s/%s/raw" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return the content of a snippet.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The snippet content
    """
    path = "%s/%s/raw" % (self.manager.path, self.get_id())
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def download(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Download the archive of a project export.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            reatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the server failed to perform the request

    Returns:
        str: The blob content if streamed is False, None otherwise
    """
    path = "/projects/%d/export/download" % self.project_id
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def download(self, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Download the archive of a project export.

    Args:
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            reatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the server failed to perform the request

    Returns:
        str: The blob content if streamed is False, None otherwise
    """
    path = "/projects/%d/export/download" % self.project_id
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def repository_raw_blob(
    self, sha, streamed=False, action=None, chunk_size=1024, **kwargs
):
    """Return the raw file contents for a blob.

    Args:
        sha(str): ID of the blob
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the server failed to perform the request

    Returns:
        str: The blob content if streamed is False, None otherwise
    """
    path = "/projects/%s/repository/blobs/%s/raw" % (self.get_id(), sha)
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def repository_raw_blob(
    self, sha, streamed=False, action=None, chunk_size=1024, **kwargs
):
    """Return the raw file contents for a blob.

    Args:
        sha(str): ID of the blob
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the server failed to perform the request

    Returns:
        str: The blob content if streamed is False, None otherwise
    """
    path = "/projects/%s/repository/blobs/%s/raw" % (self.get_id(), sha)
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
def snapshot(self, wiki=False, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return a snapshot of the repository.

    Args:
        wiki (bool): If True return the wiki repository
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The uncompressed tar archive of the repository
    """
    path = "/projects/%d/snapshot" % self.get_id()
    result = self.manager.gitlab.http_get(path, streamed=streamed, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)


# Traceback (AttributeError)
(venv) ╭─user ~/Repositories/ExampleRepo  ‹feature/ci-ci-testing*›
╰─$ python gitlab_artifact.py                                      1 ↵
Traceback (most recent call last):
File "gitlab_artifact.py", line 60, in <module>
main()
File "gitlab_artifact.py", line 52, in main
a = most_recent_job.artifact("ExampleRepo/cached_service_specs.json")
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/cli.py", line 43, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
return f(*args, **kwargs)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/v4/objects.py", line 1397, in artifact
return utils.response_content(result, streamed, action, chunk_size)
File "/Users/lknecht/Repositories/ExampleRepo/venv/lib/python3.7/site-packages/gitlab/utils.py", line 28, in response_content
return response.content
AttributeError: 'list' object has no attribute 'content'

# Fixed code
def snapshot(self, wiki=False, streamed=False, action=None, chunk_size=1024, **kwargs):
    """Return a snapshot of the repository.

    Args:
        wiki (bool): If True return the wiki repository
        streamed (bool): If True the data will be processed by chunks of
            `chunk_size` and each chunk is passed to `action` for
            treatment.
        action (callable): Callable responsible of dealing with chunk of
            data
        chunk_size (int): Size of each chunk
        **kwargs: Extra options to send to the server (e.g. sudo)

    Raises:
        GitlabAuthenticationError: If authentication is not correct
        GitlabGetError: If the content could not be retrieved

    Returns:
        str: The uncompressed tar archive of the repository
    """
    path = "/projects/%d/snapshot" % self.get_id()
    result = self.manager.gitlab.http_get(path, streamed=streamed, raw=True, **kwargs)
    return utils.response_content(result, streamed, action, chunk_size)
# Buggy code
async def get_keys(self, region: str):
    try:
        keys = await AWSFacadeUtils.get_all_pages(
            "kms", region, self.session, "list_keys", "Keys"
        )
        await get_and_set_concurrently(
            [
                self._get_and_set_key_policy,
                self._get_and_set_key_metadata,
                self._get_and_set_key_rotation_status,
                self._get_and_set_key_aliases,
            ],
            keys,
            region=region,
        )
    except Exception as e:
        print_exception("Failed to get KMS keys: {}".format(e))
        keys = []
    finally:
        return keys


# Traceback (botocore.exceptions.ClientError)
Traceback (most recent call last):
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in _get_and_set_key_rotation_status
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/utils.py", line 24, in run_concurrently
return await run_function_concurrently(function)
File "<redactedPath>/.pyenv/versions/3.7.2/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in <lambda>
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 626, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the GetKeyRotationStatus operation: User: arn:aws:sts::<redacted>:assumed-role/<redacted>/<redacted> is not authorized to perform: kms:GetKeyRotationStatus on resource: arn:aws:kms:us-east-1:<redacted>:key/<redacted>

# Fixed code
async def get_keys(self, region: str):
    try:
        keys = await AWSFacadeUtils.get_all_pages(
            "kms", region, self.session, "list_keys", "Keys"
        )
        await get_and_set_concurrently(
            [
                self._get_and_set_key_policy,
                self._get_and_set_key_metadata,
                self._get_and_set_key_aliases,
            ],
            keys,
            region=region,
        )
    except Exception as e:
        print_exception("Failed to get KMS keys: {}".format(e))
        keys = []
    finally:
        return keys
# Buggy code
async def fetch_all(self):
    raw_keys = await self.facade.kms.get_keys(self.region)
    for raw_key in raw_keys:
        key_id, key = self._parse_key(raw_key)
        self[key_id] = key

    await self._fetch_children_of_all_resources(
        resources=self,
        scopes={
            key_id: {"region": self.region, "key_id": key["id"]}
            for (key_id, key) in self.items()
        },
    )


# Traceback (botocore.exceptions.ClientError)
Traceback (most recent call last):
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in _get_and_set_key_rotation_status
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/utils.py", line 24, in run_concurrently
return await run_function_concurrently(function)
File "<redactedPath>/.pyenv/versions/3.7.2/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in <lambda>
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 626, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the GetKeyRotationStatus operation: User: arn:aws:sts::<redacted>:assumed-role/<redacted>/<redacted> is not authorized to perform: kms:GetKeyRotationStatus on resource: arn:aws:kms:us-east-1:<redacted>:key/<redacted>

# Fixed code
async def fetch_all(self):
    raw_keys = await self.facade.kms.get_keys(self.region)
    for raw_key in raw_keys:
        key_id, key = await self._parse_key(raw_key)
        self[key_id] = key

    await self._fetch_children_of_all_resources(
        resources=self,
        scopes={
            key_id: {"region": self.region, "key_id": key["id"]}
            for (key_id, key) in self.items()
        },
    )
# Buggy code
def _parse_alias(self, raw_alias):
    alias_dict = {
        # all KMS Aliases are prefixed with alias/, so we'll strip that off
        "id": get_non_provider_id(raw_alias.get("AliasArn")),
        "name": raw_alias.get("AliasName").split("alias/", 1)[-1],
        "arn": raw_alias.get("AliasArn"),
        "key_id": raw_alias.get("TargetKeyId"),
    }
    return alias_dict["id"], alias_dict


# Traceback (botocore.exceptions.ClientError)
Traceback (most recent call last):
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in _get_and_set_key_rotation_status
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/utils.py", line 24, in run_concurrently
return await run_function_concurrently(function)
File "<redactedPath>/.pyenv/versions/3.7.2/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/ScoutSuite/providers/aws/facade/kms.py", line 41, in <lambda>
lambda: client.get_key_rotation_status(KeyId=key['KeyId']))
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "<redactedPath>env/lib/python3.7/site-packages/botocore/client.py", line 626, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the GetKeyRotationStatus operation: User: arn:aws:sts::<redacted>:assumed-role/<redacted>/<redacted> is not authorized to perform: kms:GetKeyRotationStatus on resource: arn:aws:kms:us-east-1:<redacted>:key/<redacted>

# Fixed code
def _parse_alias(self, raw_alias):
    alias_dict = {
        # all KMS Aliases are prefixed with alias/, so we'll strip that off
        "id": get_non_provider_id(raw_alias.get("AliasArn")),
        "name": raw_alias.get("AliasName").split("alias/", 1)[-1],
        "arn": raw_alias.get("AliasArn"),
        "key_id": raw_alias.get("TargetKeyId"),
    }
    return alias_dict
# Buggy code
def _has_full_access_to_all_cloud_apis(self, raw_instance):
    full_access_scope = "https://www.googleapis.com/auth/cloud-platform"
    return any(
        full_access_scope in service_account["scopes"]
        for service_account in raw_instance["serviceAccounts"]
    )


# Traceback (KeyError)
$ scout gcp --user-account
Task exception was never retrieved
future: <Task finished coro=<Instances.fetch_all() done, defined at /home/user/.local/lib/python3.7/site-packages/ScoutSuite/providers/gcp/resources/gce/instances.py:17> exception=KeyError('serviceAccounts')>
Traceback (most recent call last):
File "/home/user/.local/lib/python3.7/site-packages/ScoutSuite/providers/gcp/resources/gce/instances.py", line 20, in fetch_all
instance_id, instance = self._parse_instance(raw_instance)
File "/home/user/.local/lib/python3.7/site-packages/ScoutSuite/providers/gcp/resources/gce/instances.py", line 36, in _parse_instance
instance_dict['service_accounts'] = raw_instance['serviceAccounts']
KeyError: 'serviceAccounts'

# Fixed code
def _has_full_access_to_all_cloud_apis(self, raw_instance):
    full_access_scope = "https://www.googleapis.com/auth/cloud-platform"
    return any(
        full_access_scope in service_account["scopes"]
        for service_account in raw_instance.get("serviceAccounts", [])
    )
# Buggy code
def preprocessing(self, ip_ranges=None, ip_ranges_name_key=None):
    """
    Tweak the AWS config to match cross-service resources and clean any fetching artifacts

    :param ip_ranges:
    :param ip_ranges_name_key:
    :return: None
    """
    ip_ranges = [] if ip_ranges is None else ip_ranges
    self._map_all_sgs()
    self._map_all_subnets()
    self._set_emr_vpc_ids()
    # self.parse_elb_policies()

    # Various data processing calls
    self._add_security_group_name_to_ec2_grants()
    self._add_last_snapshot_date_to_ec2_volumes()
    self._process_cloudtrail_trails(self.services["cloudtrail"])
    self._add_cidr_display_name(ip_ranges, ip_ranges_name_key)
    self._merge_route53_and_route53domains()
    self._match_instances_and_roles()
    self._match_iam_policies_and_buckets()

    super(AWSProvider, self).preprocessing()


# Traceback (NameError)
File '/report/inc-awsconfig/exceptions.js' already exists. Do you want to overwrite it (y/n)?
EOF when reading a lineCreating /report/report.html ...

File '/report/report.html' already exists. Do you want to overwrite it (y/n)? Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/AWSScout2/output/utils.py", line 22, in prompt_4_yes_no
choice = raw_input().lower()
NameError: name 'raw_input' is not defined

# Fixed code
def preprocessing(self, ip_ranges=None, ip_ranges_name_key=None):
    """
    Tweak the AWS config to match cross-service resources and clean any fetching artifacts

    :param ip_ranges:
    :param ip_ranges_name_key:
    :return: None
    """
    ip_ranges = [] if ip_ranges is None else ip_ranges
    self._map_all_sgs()
    self._map_all_subnets()
    self._set_emr_vpc_ids()
    # self.parse_elb_policies()

    # Various data processing calls
    self._check_ec2_zone_distribution()
    self._add_security_group_name_to_ec2_grants()
    self._add_last_snapshot_date_to_ec2_volumes()
    self._process_cloudtrail_trails(self.services["cloudtrail"])
    self._add_cidr_display_name(ip_ranges, ip_ranges_name_key)
    self._merge_route53_and_route53domains()
    self._match_instances_and_roles()
    self._match_iam_policies_and_buckets()

    super(AWSProvider, self).preprocessing()
# Buggy code
def __init__(self, metadata=None, thread_config=4, **kwargs):
    self.storageaccounts = StorageAccountsConfig(thread_config=thread_config)
    self.monitor = MonitorConfig(thread_config=thread_config)
    self.sqldatabase = SQLDatabaseConfig(thread_config=thread_config)
    self.securitycenter = SecurityCenterConfig(thread_config=thread_config)
    self.keyvault = KeyVaultConfig(thread_config=thread_config)

    try:
        self.appgateway = AppGatewayConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.rediscache = RedisCacheConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.loadbalancer = LoadBalancerConfig(thread_config=thread_config)
    except NameError:
        pass


# Traceback (NameError)
File '/report/inc-awsconfig/exceptions.js' already exists. Do you want to overwrite it (y/n)?
EOF when reading a lineCreating /report/report.html ...

File '/report/report.html' already exists. Do you want to overwrite it (y/n)? Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/AWSScout2/output/utils.py", line 22, in prompt_4_yes_no
choice = raw_input().lower()
NameError: name 'raw_input' is not defined

# Fixed code
def __init__(self, metadata=None, thread_config=4, **kwargs):
    self.storageaccounts = StorageAccountsConfig(thread_config=thread_config)
    self.monitor = MonitorConfig(thread_config=thread_config)
    self.sqldatabase = SQLDatabaseConfig(thread_config=thread_config)
    self.securitycenter = SecurityCenterConfig(thread_config=thread_config)
    self.network = NetworkConfig(thread_config=thread_config)
    self.keyvault = KeyVaultConfig(thread_config=thread_config)

    try:
        self.appgateway = AppGatewayConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.rediscache = RedisCacheConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.appservice = AppServiceConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.loadbalancer = LoadBalancerConfig(thread_config=thread_config)
    except NameError:
        pass
# Buggy code
def __init__(self, metadata=None, thread_config=4, **kwargs):
    self.storageaccounts = StorageAccountsConfig(thread_config=thread_config)
    self.monitor = MonitorConfig(thread_config=thread_config)
    self.sqldatabase = SQLDatabaseConfig(thread_config=thread_config)
    self.securitycenter = SecurityCenterConfig(thread_config=thread_config)
    self.network = NetworkConfig(thread_config=thread_config)
    self.keyvault = KeyVaultConfig(thread_config=thread_config)

    try:
        self.appgateway = AppGatewayConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.rediscache = RedisCacheConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.appservice = AppServiceConfig(thread_config=thread_config)
    except NameError:
        pass


# Traceback (NameError)
File '/report/inc-awsconfig/exceptions.js' already exists. Do you want to overwrite it (y/n)?
EOF when reading a lineCreating /report/report.html ...

File '/report/report.html' already exists. Do you want to overwrite it (y/n)? Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/AWSScout2/output/utils.py", line 22, in prompt_4_yes_no
choice = raw_input().lower()
NameError: name 'raw_input' is not defined

# Fixed code
def __init__(self, metadata=None, thread_config=4, **kwargs):
    self.storageaccounts = StorageAccountsConfig(thread_config=thread_config)
    self.monitor = MonitorConfig(thread_config=thread_config)
    self.sqldatabase = SQLDatabaseConfig(thread_config=thread_config)
    self.securitycenter = SecurityCenterConfig(thread_config=thread_config)
    self.network = NetworkConfig(thread_config=thread_config)
    self.keyvault = KeyVaultConfig(thread_config=thread_config)

    try:
        self.appgateway = AppGatewayConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.rediscache = RedisCacheConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.appservice = AppServiceConfig(thread_config=thread_config)
    except NameError:
        pass
    try:
        self.loadbalancer = LoadBalancerConfig(thread_config=thread_config)
    except NameError:
        pass
# Buggy code
def output(self, outs, msg, display_id, cell_index):
    if self.clear_before_next_output:
        self.outputs = []
        self.clear_before_next_output = False
    self.parent_header = msg["parent_header"]
    content = msg["content"]
    if "data" not in content:
        output = {
            "output_type": "stream",
            "text": content["text"],
            "name": content["name"],
        }
    else:
        data = content["data"]
        output = {"output_type": "display_data", "data": data, "metadata": {}}
    self.outputs.append(output)
    self.sync_state()
    if hasattr(self.executor, "widget_state"):
        # sync the state to the nbconvert state as well, since that is used for testing
        self.executor.widget_state[self.comm_id]["outputs"] = self.outputs


# Traceback (KeyError)
Traceback (most recent call last):
...
File "/opt/anaconda3/lib/python3.7/site-packages/voila/execute.py", line 79, in set_state
del self.executor.output_hook[self.msg_id]
KeyError: 'e7108564-b1a38beaf451e1c7095357b2'

# Fixed code
def output(self, outs, msg, display_id, cell_index):
    if self.clear_before_next_output:
        self.outputs = []
        self.clear_before_next_output = False
    self.parent_header = msg["parent_header"]
    content = msg["content"]
    if "data" not in content:
        output = {
            "output_type": "stream",
            "text": content["text"],
            "name": content["name"],
        }
    else:
        data = content["data"]
        output = {"output_type": "display_data", "data": data, "metadata": {}}
    if self.outputs:
        # try to coalesce/merge output text
        last_output = self.outputs[-1]
        if (
            last_output["output_type"] == "stream"
            and output["output_type"] == "stream"
            and last_output["name"] == output["name"]
        ):
            last_output["text"] += output["text"]
        else:
            self.outputs.append(output)
    else:
        self.outputs.append(output)
    self.sync_state()
    if hasattr(self.executor, "widget_state"):
        # sync the state to the nbconvert state as well, since that is used for testing
        self.executor.widget_state[self.comm_id]["outputs"] = self.outputs
# Buggy code
def set_state(self, state):
    if "msg_id" in state:
        msg_id = state.get("msg_id")
        if msg_id:
            self.executor.output_hook[msg_id] = self
            self.msg_id = msg_id
        else:
            del self.executor.output_hook[self.msg_id]
            self.msg_id = msg_id


# Traceback (KeyError)
Traceback (most recent call last):
...
File "/opt/anaconda3/lib/python3.7/site-packages/voila/execute.py", line 79, in set_state
del self.executor.output_hook[self.msg_id]
KeyError: 'e7108564-b1a38beaf451e1c7095357b2'

# Fixed code
def set_state(self, state):
    if "msg_id" in state:
        msg_id = state.get("msg_id")
        if msg_id:
            self.executor.register_output_hook(msg_id, self)
            self.msg_id = msg_id
        else:
            self.executor.remove_output_hook(self.msg_id, self)
            self.msg_id = msg_id
# Buggy code
def preprocess(self, nb, resources, km=None):
    self.output_hook = {}
    self.output_objects = {}
    try:
        result = super(VoilaExecutePreprocessor, self).preprocess(
            nb, resources=resources, km=km
        )
    except CellExecutionError as e:
        self.log.error(e)
        result = (nb, resources)
    return result


# Traceback (KeyError)
Traceback (most recent call last):
...
File "/opt/anaconda3/lib/python3.7/site-packages/voila/execute.py", line 79, in set_state
del self.executor.output_hook[self.msg_id]
KeyError: 'e7108564-b1a38beaf451e1c7095357b2'

# Fixed code
def preprocess(self, nb, resources, km=None):
    self.output_hook_stack = collections.defaultdict(
        list
    )  # maps to list of hooks, where the last is used
    self.output_objects = {}
    try:
        result = super(VoilaExecutePreprocessor, self).preprocess(
            nb, resources=resources, km=km
        )
    except CellExecutionError as e:
        self.log.error(e)
        result = (nb, resources)
    return result
# Buggy code
def output(self, outs, msg, display_id, cell_index):
    parent_msg_id = msg["parent_header"].get("msg_id")
    if parent_msg_id in self.output_hook:
        self.output_hook[parent_msg_id].output(outs, msg, display_id, cell_index)
        return
    super(VoilaExecutePreprocessor, self).output(outs, msg, display_id, cell_index)


# Traceback (KeyError)
Traceback (most recent call last):
...
File "/opt/anaconda3/lib/python3.7/site-packages/voila/execute.py", line 79, in set_state
del self.executor.output_hook[self.msg_id]
KeyError: 'e7108564-b1a38beaf451e1c7095357b2'

# Fixed code
def output(self, outs, msg, display_id, cell_index):
    parent_msg_id = msg["parent_header"].get("msg_id")
    if self.output_hook_stack[parent_msg_id]:
        hook = self.output_hook_stack[parent_msg_id][-1]
        hook.output(outs, msg, display_id, cell_index)
        return
    super(VoilaExecutePreprocessor, self).output(outs, msg, display_id, cell_index)
# Buggy code
def clear_output(self, outs, msg, cell_index):
    parent_msg_id = msg["parent_header"].get("msg_id")
    if parent_msg_id in self.output_hook:
        self.output_hook[parent_msg_id].clear_output(outs, msg, cell_index)
        return
    super(VoilaExecutePreprocessor, self).clear_output(outs, msg, cell_index)


# Traceback (KeyError)
Traceback (most recent call last):
...
File "/opt/anaconda3/lib/python3.7/site-packages/voila/execute.py", line 79, in set_state
del self.executor.output_hook[self.msg_id]
KeyError: 'e7108564-b1a38beaf451e1c7095357b2'

# Fixed code
def clear_output(self, outs, msg, cell_index):
    parent_msg_id = msg["parent_header"].get("msg_id")
    if self.output_hook_stack[parent_msg_id]:
        hook = self.output_hook_stack[parent_msg_id][-1]
        hook.clear_output(outs, msg, cell_index)
        return
    super(VoilaExecutePreprocessor, self).clear_output(outs, msg, cell_index)