From c1342402507187ef2a724540650d5897b529c82f Mon Sep 17 00:00:00 2001 From: ma Date: Sun, 25 Jul 2021 15:01:16 +0200 Subject: [PATCH 1/2] Dont use sudo while creating milestones. During migration of some bugzilla tickets i noticed random 403 forbidden errors during milestone creation. Just as during issue creation, the sudo flag is set for creating a milestone too, means it attempts to create the milestone with the user the current ticket is processed (and which was missing some access rights in my case). As we are using an administrative account for migration anyways its not requird to set sudo value in the headers and i think it is perfectly fine to use the project's administrative account to create them. --- bugzilla2gitlab/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bugzilla2gitlab/models.py b/bugzilla2gitlab/models.py index 282de9c..a0bf4f3 100644 --- a/bugzilla2gitlab/models.py +++ b/bugzilla2gitlab/models.py @@ -126,10 +126,15 @@ def create_milestone(self, milestone): url = "{}/projects/{}/milestones".format( CONF.gitlab_base_url, CONF.gitlab_project_id ) + """ + Dont use sudo while creating milestones + """ + header = self.headers + del header["sudo"] response = _perform_request( url, "post", - headers=self.headers, + headers=header, data={"title": milestone}, verify=CONF.verify, ) From 46cebdb5c9a2fcb90c8da80ccf24d980ad0f568b Mon Sep 17 00:00:00 2001 From: ma Date: Sun, 25 Jul 2021 23:19:27 +0200 Subject: [PATCH 2/2] only remove header if set --- bugzilla2gitlab/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bugzilla2gitlab/models.py b/bugzilla2gitlab/models.py index a0bf4f3..b009a69 100644 --- a/bugzilla2gitlab/models.py +++ b/bugzilla2gitlab/models.py @@ -130,7 +130,8 @@ def create_milestone(self, milestone): Dont use sudo while creating milestones """ header = self.headers - del header["sudo"] + if "sudo" in header: + del header["sudo"] response = _perform_request( url, "post",