Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

BadZipFile error #32

Open
josjaf opened this issue May 1, 2019 · 4 comments
Open

BadZipFile error #32

josjaf opened this issue May 1, 2019 · 4 comments

Comments

@josjaf
Copy link
Contributor

josjaf commented May 1, 2019

Hi I'm getting a badzipfile error. When i wget the file in the lambda logs that shows the zip file, it's definitely a zip. Also, is there a way to include the .git dir from the provider?

File is not a zip file: BadZipfile
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 121, in lambda_handler
zip = ZipFile(f)
File "/usr/lib64/python2.7/zipfile.py", line 770, in __init__
self._RealGetContents()
File "/usr/lib64/python2.7/zipfile.py", line 811, in _RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file
@josjaf
Copy link
Contributor Author

josjaf commented May 1, 2019

It doesn't look like the call to the gitlab api is working. Here is what I did for python3.

    elif hostflavour == 'gitlab':
        # https://gitlab.com/jaymcconnell/gitlab-test-30/repository/archive.zip?ref=master
        print(event['body-json']['project']['http_url'])

        archive_root = event['body-json']['project']['http_url'].strip('.git')

        project_id = event['body-json']['project_id']
        branch = event['body-json']['ref'].replace('refs/heads/', '')
        archive_url = f"https://gitlab.com/api/v4/projects/{project_id}/repository/archive.zip"
        params = {'private_token': OAUTH_token, 'ref': 'branch'}

        owner = event['body-json']['project']['namespace']
        name = event['body-json']['project']['name']
r = requests.get(archive_url, verify=verify, headers=headers, params=params)

@jaymccon
Copy link
Contributor

jaymccon commented May 2, 2019

Thanks for posting the fix @josjaf would you be willing to put in a pr ? Also happy to put it in the patch on your behalf if you'd prefer.

@josjaf
Copy link
Contributor Author

josjaf commented May 3, 2019

I'll send over a PR at some point. 'branch' needs to be branch - variable instead of string

 params = {'private_token': OAUTH_token, 'sha': branch}

ref is not longer used.

@nediml
Copy link

nediml commented Jul 22, 2020

In case somebody has Gitlab CE on his own servers and wants to use this quick start it is just needed to modify archive_url to reflect the url of the custom Gitlab CE.
archive_url = f"https://GITLAB_CE_URL/api/v4/projects/{project_id}/repository/archive.zip"

I am surprised that this is not parameterized already by AWS team...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants