fix: add missing model_activity.delay() for API-driven issue webhooks - #8792
Conversation
…webhook dispatch Fixes #6746 API-driven issue updates (PUT update, PUT create-via-upsert, PATCH) were missing `model_activity.delay()` calls, so webhooks were never dispatched for changes made through the API. The web UI paths already include these calls (e.g. in `post()` at L475), but the `put()` and `partial_update()` methods only called `issue_activity.delay()`. This adds `model_activity.delay()` immediately after each existing `issue_activity.delay()` in these three code paths, using the same signature as the existing call in `post()`. Tested on Plane CE v1.2.1 self-hosted: API PATCH triggers `webhook_send_task` in the Celery worker, confirming webhook delivery. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded webhook dispatch calls to the issue detail API endpoint's PUT and PATCH methods. The changes ensure that whenever issues are created or updated via the API, corresponding Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds the missing model_activity.delay() calls to the issue API update/upsert code paths so Celery can trigger webhook dispatch for API-driven issue changes (matching the existing web UI behavior).
Changes:
- Trigger
model_activity.delay()after issue updates inPUT(existing issue viaexternal_id). - Trigger
model_activity.delay()after issue creation inPUTupsert flow (new issue viaexternal_id). - Trigger
model_activity.delay()afterPATCHpartial updates.
| # Send the model activity for webhook dispatch | ||
| model_activity.delay( | ||
| model_name="issue", | ||
| model_id=str(issue.id), | ||
| requested_data=request.data, | ||
| current_instance=current_instance, | ||
| actor_id=request.user.id, | ||
| slug=slug, | ||
| origin=base_host(request=request, is_app=True), | ||
| ) |
There was a problem hiding this comment.
Consider adding an automated regression test that asserts model_activity.delay() is triggered for issue PUT/PATCH API updates (in addition to issue_activity.delay()), since this PR fixes webhook dispatching via model_activity and it’s easy to accidentally regress in future refactors. A lightweight approach is to patch plane.bgtasks.webhook_task.model_activity.delay (or Celery Task.delay) and verify it’s called on update and create-via-upsert paths.
Summary
Fixes #6746 — Webhooks are not triggered when issues are created or updated via the API.
Problem
The
put()(update and create-via-upsert) andpartial_update()methods inapps/api/plane/api/views/issue.pyonly callissue_activity.delay()but notmodel_activity.delay(). Sincemodel_activityis what triggerswebhook_activity→webhook_send_taskin the Celery worker, webhooks are never dispatched for API-driven issue changes.The web UI code paths (e.g.
post()at L475) already includemodel_activity.delay(), so this is only missing from the API views.Fix
Added
model_activity.delay()immediately after each existingissue_activity.delay()in three locations:external_idexternal_idUses the same function signature as the existing
model_activity.delay()call inpost().Testing
Tested on Plane CE v1.2.1 (self-hosted, Docker):
PATCHrequest via API to update issue prioritymodel_activitytask receivedwebhook_activitytask receivedwebhook_send_tasksent successfullyBefore the fix, none of these tasks were triggered for API-driven updates.
Summary by CodeRabbit