fix: call revoke_line_items_task directly instead of via signal - #542
fix: call revoke_line_items_task directly instead of via signal#542bseverino wants to merge 2 commits into
Conversation
The revoke task was wired through a Django signal (fulfill_order_returned_send_revoke_line_items_signal) that required CC_SIGNALS configuration. In production the YAML config overrides CC_SIGNALS, and the new signal entry was missing, so send_robust() silently dispatched to zero receivers and the task was never enqueued. Replace the signal indirection with a direct .delay() call since both the caller and callee live in the same app. Also sync test.py CC_SIGNALS with base.py for other missing entries. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Replaces an indirect signal dispatch (fulfill_order_returned_send_revoke_line_items_signal.send_robust(...)) with a direct Celery task invocation (revoke_line_items_task.delay(...)) to eliminate a silent failure mode where production YAML config could override CC_SIGNALS and leave the signal with zero receivers. The signal definition, its CC_SIGNALS entry, and related test wiring are removed/updated accordingly, and settings/test.py is brought back in sync with settings/base.py.
Changes:
- Replace signal
send_robustwith directrevoke_line_items_task.delaycall insub_messages/tasks.py; drop the now-unused signal definition and itsCC_SIGNALSentry. - Update task tests to mock
revoke_line_items_taskand assert on.delay(...)calls; switchRevokeLineItemsTestto fire viaexample_signal. - Add missing
entitlement, PayPal, and IAP/mobile signal entries tosettings/test.pyto matchsettings/base.py.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| commerce_coordinator/apps/commercetools/sub_messages/tasks.py | Replace signal send with direct revoke_line_items_task.delay(...) and update imports. |
| commerce_coordinator/apps/commercetools/signals.py | Remove the unused fulfill_order_returned_send_revoke_line_items_signal definition. |
| commerce_coordinator/settings/base.py | Remove the corresponding CC_SIGNALS entry. |
| commerce_coordinator/settings/test.py | Add missing entitlement/PayPal/IAP signal entries to align with base.py. |
| commerce_coordinator/apps/commercetools/tests/sub_messages/test_tasks.py | Mock revoke_line_items_task and assert on .delay(...) instead of send_robust. |
| commerce_coordinator/apps/commercetools/tests/test_signals.py | Drop unused import; use example_signal to test the revoke_line_items receiver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Cursor <cursoragent@cursor.com>
4e9a802 to
d9cd12e
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fulfill_order_returned_signal_taskwas usingsend_robust()on a Django signal (fulfill_order_returned_send_revoke_line_items_signal) to triggerrevoke_line_items_task. This required the signal to be wired inCC_SIGNALS, which could be silently overridden by the production YAML config (vars().update(config_from_yaml)inproduction.py). Whensend_robust()has zero connected receivers, it returns an empty list without raising -- so the failure was completely silent.Changes made across 6 files:
sub_messages/tasks.py-- Replacedfulfill_order_returned_send_revoke_line_items_signal.send_robust(...)with a direct call torevoke_line_items_task.delay(order_id=order_id, return_items=return_items). This eliminates the fragile signal indirection since both the caller and callee are within the same app.signals.py-- Removed thefulfill_order_returned_send_revoke_line_items_signaldefinition (no longer needed). Therevoke_line_itemsreceiver function remains available.settings/base.py-- Removed thefulfill_order_returned_send_revoke_line_items_signal entryfromCC_SIGNALS.tests/sub_messages/test_tasks.py-- Updated bothOrderReturnedMessageSignalTaskTestsandFulfillOrderReturnedSignalTaskTeststo mockrevoke_line_items_taskinstead ofsend_robust, and assert on.delay()calls.tests/test_signals.py-- UpdatedRevokeLineItemsTestto useexample_signalinstead of the deleted signal, and removed the unused import.settings/test.py-- Added missing signal entries (entitlement, PayPal, IAP/mobile) to keepCC_SIGNALSin sync with base.py.Internal ticket: https://redventures.atlassian.net/browse/RV2U-473