Skip to content

feat(gitlab): add webhook handling, tagging, and shared VCS module#7122

Open
asaphko wants to merge 2 commits intofeature/gitlab-configfrom
feature/gitlab-webhook
Open

feat(gitlab): add webhook handling, tagging, and shared VCS module#7122
asaphko wants to merge 2 commits intofeature/gitlab-configfrom
feature/gitlab-webhook

Conversation

@asaphko
Copy link
Copy Markdown
Contributor

@asaphko asaphko commented Apr 3, 2026

Add webhook endpoint, event-driven feature tagging, and async comment posting for the GitLab integration. Also extract shared VCS comment generation used by both GitHub and GitLab. Third PR in the stacked series splitting #7028.

Changes

  • Webhook endpoint at /api/v1/gitlab-webhook/<project_pk>/ with token validation
  • Event-driven tagging: MR/issue state changes auto-tag linked features
  • Async comment posting via task processor (credentials fetched from DB, never queued)
  • Shared integrations/vcs/ module: comment generation, constants, feature state helpers
  • Refactored GitHub generate_body_comment to delegate to shared VCS module
  • Business logic in services.py, data mapping in mappers.py, thin tasks.py
  • 19 tests: parametrised tag mapping, webhook integration tests, tagging integration tests

Contributes to #7028
Stacks on #7121

Review effort: 3/5

Review feedback addressed from #7028

  • No credentials in task args (khvn26: "Don't pass private credentials around in task processor args")
  • Simplified task chain — task fetches config from DB, no intermediate dataclass reassembly (khvn26: 5-layer call stack critique)
  • Module placement per architecture guidelinesservices.py for business logic, mappers.py for data mapping, tasks.py as thin entry point (khvn26, per api/README.md)
  • Shared VCS moduleintegrations/vcs/ for comment generation (khvn26: "this logic should be abstracted out")
  • GitHub refactored to use shared generate_body_comment (emyller: "why not interfacing with this function directly")
  • tag_by_event_type uses GitLabTag enum not raw strings (khvn26)
  • Webhook validation inline — removed helpers.py (emyller: "doesn't look much of a helper")
  • Deduplicated handle_gitlab_webhook_event branches (emyller)
  • Integration tests for tagging with real DB, parametrised tag mapping (khvn26, Zaimwa9)
  • GitLab docs reference in webhook view docstring (emyller)

Not yet included (follow-up)

  • Feature model hooks (features/models.py, features/serializers.py) calling dispatch_gitlab_comment — these mirror the existing GitHub pattern and will be added once this PR's architecture is approved
  • feature_external_resources/views.py GitLab metadata enrichment
  • feature_external_resources/models.py lifecycle hooks for GitLab

🤖 Generated with Claude Code

Add webhook endpoint, event-driven tagging, async comment posting,
and extract shared VCS comment generation from the GitHub integration.

Key architectural improvements over #7028:
- Credentials never passed through task queue (security)
- Business logic in services.py, data mapping in mappers.py
- Thin task entry point fetches config from DB
- Shared VCS module for comment generation (GitHub refactored too)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@asaphko asaphko requested a review from a team as a code owner April 3, 2026 13:30
@asaphko asaphko requested review from khvn26 and removed request for a team April 3, 2026 13:30
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.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Apr 3, 2026 1:31pm
flagsmith-frontend-preview Ignored Ignored Preview Apr 3, 2026 1:31pm
flagsmith-frontend-staging Ignored Ignored Preview Apr 3, 2026 1:31pm

Request Review

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Docker builds report

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  44.7 seconds
commit  bb36a84
info  🔄 Run: #15696 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  24.7 seconds
commit  adb7cc3
info  🔄 Run: #15697 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  28 seconds
commit  adb7cc3
info  🔄 Run: #15697 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  28.5 seconds
commit  bb36a84
info  🔄 Run: #15696 (attempt 1)

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

passed  16 passed

Details

stats  16 tests across 13 suites
duration  37.9 seconds
commit  bb36a84
info  🔄 Run: #15696 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  50.2 seconds
commit  bb36a84
info  🔄 Run: #15696 (attempt 1)

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 69.42446% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.10%. Comparing base (a791102) to head (adb7cc3).
⚠️ Report is 1 commits behind head on feature/gitlab-config.

Files with missing lines Patch % Lines
api/integrations/gitlab/tasks.py 0.00% 53 Missing ⚠️
api/integrations/gitlab/mappers.py 25.00% 15 Missing ⚠️
api/integrations/vcs/helpers.py 0.00% 10 Missing ⚠️
api/integrations/gitlab/services.py 87.93% 7 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           feature/gitlab-config    #7122      +/-   ##
=========================================================
- Coverage                  98.26%   98.10%   -0.16%     
=========================================================
  Files                       1353     1360       +7     
  Lines                      50436    50685     +249     
=========================================================
+ Hits                       49560    49724     +164     
- Misses                       876      961      +85     

☔ 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.

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 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant