Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with unprotect_branch_new_api #219

Closed
bethmal opened this issue May 24, 2021 · 8 comments · Fixed by #230
Closed

Issue with unprotect_branch_new_api #219

bethmal opened this issue May 24, 2021 · 8 comments · Fixed by #230
Labels

Comments

@bethmal
Copy link

bethmal commented May 24, 2021

Hi,
In version 2.0.0post1,

  1. Procedure _make_requests_to_api, core.py line 113: exception when response.status_code is 404, exception message "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)".

  2. Procedure _make_request_to_api, core.py line 208,: exception when response.status_code is 404, exception message "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)".

Seems expected_codes contains code 404, not quite understand why the judgement in line 192 of core.py is presented.

        if response.status_code == 404:
            raise NotFoundException("Resource path='%s' not found!" % url)
  1. In branch_protector.py line 53, exception when response has no "unprotect_access_levels".

Thanks.

@gdubicki
Copy link
Member

gdubicki commented May 24, 2021

Hi @bethmal !

Thanks for reporting the issues.

It would help if you could provide some more context though. Preferably configuration snippets that have caused those errors.

Ad 3: can you take a look a this please, @YuraBeznos ? Maybe it will be obvious to you what is the cause.

@bethmal
Copy link
Author

bethmal commented May 25, 2021

@gdubicki
Please find below configuration snippets. Basically the case is like:

If unprotect_access_level is not provided in configuration yml file, and meanwhile master branch is not protected (the reason could be either it was not protected on purpose or is was unprotected by gitlabform ), then procedure protect_branch does nothing. In this scenario, if a file need to be updated as well, the re-protect operation fails after the file is pushed.

If master branch is not protected (the reason could be either it was not protected on purpose or is was unprotected by gitlabform ), and then unprotect_branch_new_api is invoked somehow, exceptions mentioned above would be raised. The response code 404 is not json dump-able or loadable.

The response of get_branch_access_levels contains no unprotect_access_levels in our case.

projects_and_groups:
  "gitlabform_test/*":
    branches:
      # see comment above - this branch config will be ADDED to the branches configured on a group level
      master:
        protected: true
        push_access_level: 40
        merge_access_level: 40
        unprotect_access_level: 40

    files:
      ".gitlab/merge_request_templates/MR.md":
        overwrite: true
        branches:
          - master
        skip_ci: true
        file: MR.md

gdubicki added a commit that referenced this issue May 28, 2021
and a test that shows that it works.

Fixes #219.
@gdubicki gdubicki reopened this May 29, 2021
gdubicki added a commit that referenced this issue May 29, 2021
using the new API.

Partially fixes #219.
@bethmal
Copy link
Author

bethmal commented Jun 4, 2021

Hi @gdubicki ,
Could 404 exception issues (protect unprotected branch) be solved as early as possible? This issue is blocking gitlabform critical feature.
Thanks.

@gdubicki
Copy link
Member

gdubicki commented Jun 5, 2021

Sorry @bethmal, but we need more contributors to get issues fixed faster. I am already doing the best I can.

Please check out v2.0.2 - it should have this issue completely fixed.

@bethmal
Copy link
Author

bethmal commented Jun 8, 2021

@gdubicki
After verified v2.0.4 release, 404 exception issue is not fixed. I made below update anyway to make it work.
gitlab/core.py: line 199
present:
if response.status_code == 204:

new:
if response.status_code == 204 or response.status_code == 404:

Please review if this fix works for all.

Thanks.

@gdubicki gdubicki reopened this Jun 8, 2021
gdubicki added a commit that referenced this issue Jun 8, 2021
to fix #219 and possibly other flows where
we expected 404 response.
gdubicki added a commit that referenced this issue Jun 8, 2021
to fix #219 and possibly other flows where
we expected 404 response.
@gdubicki
Copy link
Member

gdubicki commented Jun 8, 2021

Please check out v2.0.5rc1 v2.0.5rc2, @bethmal . (rc1 is broken, sorry)

@gdubicki gdubicki reopened this Jun 8, 2021
@bethmal
Copy link
Author

bethmal commented Jun 9, 2021

@gdubicki Thanks for the update. v2.0.5rc2 works perfect for this scenario.

@gdubicki
Copy link
Member

gdubicki commented Jun 9, 2021

Great! We just released v2.0.5 final with this fix so we can close this issue. Of course please reopen if you see any issues with this again.

@gdubicki gdubicki closed this as completed Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants