Skip to content

fix(GitLab): Orphaned feature tag after unlinking an issue or merge request#7327

Merged
khvn26 merged 1 commit intomainfrom
fix/gitlab-clear-feature-tag-on-unlink
Apr 23, 2026
Merged

fix(GitLab): Orphaned feature tag after unlinking an issue or merge request#7327
khvn26 merged 1 commit intomainfrom
fix/gitlab-clear-feature-tag-on-unlink

Conversation

@khvn26
Copy link
Copy Markdown
Member

@khvn26 khvn26 commented Apr 23, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Follow-up to #7306.

Linking a feature to a GitLab issue or merge request applies a GitLab tag (e.g. Issue Open, MR Draft). Unlinking left that tag on the feature with no corresponding FeatureExternalResource.

Introduce clear_tag_for_resource in the GitLab tagging service and wire it into dispatch_vcs_on_resource_destroy. It removes the Issue/MR-kind tag from the feature only when no other linked FER of the same kind remains — features linked to several issues, or to both an issue and an MR, keep the still-valid tag. The helper excludes resource.pk from its survivor query so it's safe to call regardless of whether the caller has already destroyed the row.

Review effort: 1/5

How did you test this code?

Unit tests for the new helper cover:

  • single FER of a kind → tag cleared
  • multiple FERs of the same kind → tag retained
  • mixed Issue + MR → only the unlinked kind's tag cleared
  • non-GitLab type → no-op

@khvn26 khvn26 requested review from a team as code owners April 23, 2026 15:37
@khvn26 khvn26 requested review from emyller and removed request for a team April 23, 2026 15:37
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, reopen this pull request to trigger a review.

@khvn26 khvn26 changed the title fix(GitLab): Orphaned feature tag after unlinking last issue or merge request fix(GitLab): Orphaned feature tag after unlinking an issue or merge request Apr 23, 2026
@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates fix and removed docs Documentation updates labels Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-7327 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-7327 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7327 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7327 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7327 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7327 Finished ✅ Results

Zaimwa9
Zaimwa9 previously approved these changes Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.42%. Comparing base (bcddaeb) to head (3847cc6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7327   +/-   ##
=======================================
  Coverage   98.42%   98.42%           
=======================================
  Files        1391     1392    +1     
  Lines       52219    52270   +51     
=======================================
+ Hits        51396    51447   +51     
  Misses        823      823           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  44.1 seconds
commit  3cc29b8
info  🔄 Run: #16291 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  10.3 seconds
commit  3cc29b8
info  🔄 Run: #16291 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  17 passed

Details

stats  17 tests across 14 suites
duration  1 minute, 1 second
commit  3cc29b8
info  🔄 Run: #16291 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  53.1 seconds
commit  3cc29b8
info  🔄 Run: #16291 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  9.7 seconds
commit  29e523a
info  🔄 Run: #16292 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  50.1 seconds
commit  29e523a
info  🔄 Run: #16292 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  17 passed

Details

stats  17 tests across 14 suites
duration  58.3 seconds
commit  29e523a
info  🔄 Run: #16292 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  54.2 seconds
commit  29e523a
info  🔄 Run: #16292 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  1.2 seconds
commit  af0e733
info  🔄 Run: #16293 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  52.2 seconds
commit  af0e733
info  🔄 Run: #16293 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  53.2 seconds
commit  af0e733
info  🔄 Run: #16293 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  43.7 seconds
commit  1eb0656
info  🔄 Run: #16295 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  50.6 seconds
commit  1eb0656
info  🔄 Run: #16295 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  17 passed

Details

stats  17 tests across 14 suites
duration  1 minute, 3 seconds
commit  1eb0656
info  🔄 Run: #16295 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.8 seconds
commit  1eb0656
info  🔄 Run: #16295 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  8.6 seconds
commit  3847cc6
info  🔄 Run: #16296 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  46.3 seconds
commit  3847cc6
info  🔄 Run: #16296 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  52.3 seconds
commit  3847cc6
info  🔄 Run: #16296 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 4 seconds
commit  3847cc6
info  🔄 Run: #16296 (attempt 1)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Visual Regression

16 screenshots compared. See report for details.
View full report

@khvn26 khvn26 force-pushed the fix/gitlab-clear-feature-tag-on-unlink branch from 3cc29b8 to 29e523a Compare April 23, 2026 16:02
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 23, 2026 5:08pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Apr 23, 2026 5:08pm
flagsmith-frontend-staging Ignored Ignored Preview Apr 23, 2026 5:08pm

Request Review

Zaimwa9
Zaimwa9 previously approved these changes Apr 23, 2026
Copy link
Copy Markdown
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, something smells in the architecture of this.

For instance, I don't like that we import the component clear_tag_for_resource, having such a generic name, into integration.vcs, but it's from GitLab domain. And I don't think the fix here is to rename GitLab service functions with a gitlab_ namespace — although that would be cool since they're exported out of integrations.gitlab it seems?

I think we should define a protocol/interface (via OOP?) that clears out the list of all use cases involved in linking to GitHub and GitLab currently, allowing us to class BitBucketService(VCSIntegrationService): later. This part might fall into the scope of #7315.

I appreciate this should have been raised in #7162, but I was not around, sorry.

… request

Follow-up to #7306. Linking a feature applied a GitLab tag; unlinking
left it on the feature with no corresponding FER. Add
clear_tag_for_resource in the tagging service and call it from
dispatch_vcs_on_resource_destroy. It removes the Issue/MR-kind tag
from the feature only when no other linked FER of the same kind
remains, so features linked to several issues (or both an issue and
an MR) keep the still-valid tag. The helper excludes `resource.pk`
from its survivor query so it works whether the caller has already
destroyed the row or not.
@khvn26 khvn26 force-pushed the fix/gitlab-clear-feature-tag-on-unlink branch from 1eb0656 to 3847cc6 Compare April 23, 2026 17:07
@github-actions github-actions Bot added docs Documentation updates fix and removed fix docs Documentation updates labels Apr 23, 2026
Copy link
Copy Markdown
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now. Thank you!

@khvn26 khvn26 merged commit 0fa5050 into main Apr 23, 2026
35 of 36 checks passed
@khvn26 khvn26 deleted the fix/gitlab-clear-feature-tag-on-unlink branch April 23, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants