feat(GitLab): Post comments when linking an issue or merge request to a Flagsmith feature#7306
Merged
feat(GitLab): Post comments when linking an issue or merge request to a Flagsmith feature#7306
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7306 +/- ##
==========================================
+ Coverage 98.39% 98.42% +0.02%
==========================================
Files 1377 1391 +14
Lines 51744 52219 +475
==========================================
+ Hits 50913 51396 +483
+ Misses 831 823 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ecdc5cb to
db215f3
Compare
db215f3 to
fc9f9eb
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fc9f9eb to
e91ee41
Compare
The previous wording ("was **enabled**/was **disabled** with value X")
implied the enable/disable transition was the change, so a value-only
change read as an enable event that happened to already be enabled.
Switch to a post-change state snapshot matching the link comment's
style, e.g. "in **Development**: ✅ Enabled, value `X`".
beep boop
4 tasks
The resource.unlinked log now fires before super().perform_destroy(), so it lands between comment.posted and webhook.deregistered. Update the assertion to match. beep boop
Zaimwa9
requested changes
Apr 23, 2026
Contributor
Zaimwa9
left a comment
There was a problem hiding this comment.
Couple of comments, besides the question around view versus model-hook. There is this comment I'd like to explore alternatives
Reviewer asked whether this was lazy due to a circular import. It isn't — move to module top. Update the patch target in the versioning test to patch where the name is consumed rather than where it originated. Addresses #7306 (comment) beep boop
Introduce post_gitlab_state_change_comment_for_feature_state in the GitLab services layer. It short-circuits when there's no environment or the project has no GitLabConfiguration, so the majority of projects without GitLab no longer pay for a queue entry and a configuration lookup per feature-state save. Swap both state-change dispatch sites (FeatureStateSerializerBasic, CustomEnvironmentFeatureVersionFeatureStateSerializer) to call the helper. Move the gating tests down to the helper level and simplify the serializer-level tests to assert dispatch delegation. Addresses #7306 (comment) beep boop
Pass a client timeout to the new create_issue_note and create_merge_request_note calls so a slow or unresponsive GitLab instance can't hang the web worker or task processor. Rename GITLAB_WEBHOOK_TIMEOUT to GITLAB_CLIENT_TIMEOUT_SECONDS to match the broader timeout sweep in #7307 and reduce future rebase friction — the constant is no longer webhook-specific now that every client call uses it. Addresses #7306 (comment) beep boop
The `else: return` arm in `_post_note_to_resource` was only reachable by calling the private helper with an unknown `resource_type`. In practice every caller passes a constrained `FeatureExternalResource.type`, so the branch is dead code. Remove it and re-cover the unparseable-URL path through `post_linked_comment` rather than the private helper. Addresses #7306 (comment) beep boop
…s/vcs Introduce integrations/vcs/services.py with dispatch_vcs_on_resource_create and dispatch_vcs_on_resource_destroy. Both fan out to the per-provider side effects (today only GitLab; GitHub and any future VCS will land alongside — #7315). FeatureExternalResourceViewSet.perform_create and .perform_destroy now just call the dispatchers, shedding the GitLab-specific branch, log emission, and task dispatch. The view is leaner and adding a new VCS becomes a one-module change rather than edits across view, model, and serializer hooks. Register integrations.vcs as a Django app so the docgen events crawler picks up resource.linked and resource.unlinked at their new location; regenerate the catalogue. Existing integration tests cover the dispatcher at 100%. Addresses #7306 (comment) beep boop
Merge the two None-checks for project_path and iid into a single combined guard, matching the pattern used in services/labels.py. Both checks now share one branch, so there's no longer an unreachable arm masked by `# pragma: no cover`. Addresses #7306 (comment) beep boop
post_state_change_comment reads feature_state.feature.project to look up the GitLabConfiguration; without feature__project in select_related this costs one extra query per comment dispatch. Addresses #7306 (comment) beep boop
Move apply_initial_tag and the webhook-deregister dispatch out of the AFTER_SAVE / AFTER_DELETE hooks on FeatureExternalResource and into dispatch_vcs_on_resource_create / dispatch_vcs_on_resource_destroy. The model's GitLab hooks (apply_gitlab_tag, deregister_gitlab_webhook) are gone; all GitLab side-effects for linking and unlinking now live in one place. Add deregister_gitlab_webhook_for_resource alongside the existing register_gitlab_webhook_for_resource helper so the dispatcher stays provider-agnostic and just calls named GitLab services. Call the destroy dispatcher after super().perform_destroy() so has_live_resource_for_path in the deregister task naturally excludes the just-removed row without a signature change.
Zaimwa9
approved these changes
Apr 23, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR! Please check the boxes below:
I have added information todocs/if required so people know about the feature.Changes
Closes #7162
Post comments to GitLab issues and merge requests when:
State-change comments render as a snapshot of the post-change state (e.g.
in **Development**: :white_check_mark: Enabled, value `X`) rather than describing the transition, which avoids misrepresenting value-only changes as enable/disable events.How did you test this code?
Unit tests covering the new service, task handlers, and hook call sites (patch coverage 100%).
Manual smoke against gitlab.com, posting to
flagsmith/webhooks-tetsing-1:Screenshots