Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the GitLab plugin to better support group-level Epics (work items) by normalizing API base URLs, adding group webhook support for “No Project” mappings, and improving inbound payload parsing for work_item/Epic events.
Changes:
- Introduces
get_api_url()and uses it to consistently target/api/v4(including uploads/connector usage). - Adds group webhook support (
groups/:id/hooks) and routes “no_project” webhook creation to group hooks. - Enhances inbound payload handling to derive project/group context for work_item/Epic events and improves event categorization/type handling.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| gitlab/transformer_functions.py | Adds API base URL normalization and a new group webhooks helper. |
| gitlab/sync.py | Updates upload URLs, improves payload-derived project/asset logic, and adjusts event parsing for work_item/Epic. |
| gitlab/mapping.py | Creates webhooks at group scope for “No Project” (epic/group) mappings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gitlab/sync.py
Outdated
| def fetch_url(self): | ||
|
|
||
| return "{}/{}".format("'https://gitlab.com",self.private_data["url"]) | ||
| return "{}/{}".format("https://gitlab.com", self.private_data["url"]) |
There was a problem hiding this comment.
Attachment URLs are being built with a hard-coded "https://gitlab.com" base. This will break downloads for self-managed GitLab instances configured via instance_details["url"]. Consider deriving the base web URL from the configured instance URL (and joining with the relative upload path) instead of forcing gitlab.com.
There was a problem hiding this comment.
this is a refactor will be handled on attachment defect item
| except Exception as e: | ||
| error_msg = 'Unable to sync comment. Error is [{}]. The comment is [{}]'.format(str(e), comment) | ||
| error_msg = 'Unable to sync comment. Error is [{}]. The comment is [{}]'.format( | ||
| str(e), payload.get("body", "") | ||
| ) |
There was a problem hiding this comment.
In the exception handler, the error message references payload.get(...), but payload is defined inside the try block and may be unbound if an exception occurs before it is assigned (e.g., formatting errors / missing keys). Define the comment body (or payload) before the try, or guard against payload not existing, to avoid masking the original exception with an UnboundLocalError.
There was a problem hiding this comment.
Checked and modified
gitlab/sync.py
Outdated
| event_type = self.event['object_attributes']["action"] | ||
| event_type = self.event['object_attributes'].get("action", "update") | ||
|
|
||
| if event_type in ('open'): |
There was a problem hiding this comment.
if event_type in ('open'): is treating ('open') as a string, so the membership check is against characters (e.g., 'p' would match). This can misclassify events. Use a direct string comparison (event_type == "open") or a real tuple (event_type in ("open",)).
| if event_type in ('open'): | |
| if event_type == "open": |
There was a problem hiding this comment.
checked and modified
No description provided.