Skip to content

fix: move revoke signal call to return view#536

Open
bseverino wants to merge 1 commit intomainfrom
bseverino/RV2U-473-move-signal-call
Open

fix: move revoke signal call to return view#536
bseverino wants to merge 1 commit intomainfrom
bseverino/RV2U-473-move-signal-call

Conversation

@bseverino
Copy link
Copy Markdown
Member

@bseverino bseverino commented Apr 21, 2026

Move revoke line items signal toOrderReturnedView instead of chaining through fulfill_order_returned_signal_task

Internal ticket: https://redventures.atlassian.net/browse/RV2U-473

Merge checklist:
Check off if complete or not applicable:

  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Post-merge:

Copilot AI review requested due to automatic review settings April 21, 2026 13:55
@bseverino bseverino requested a review from a team as a code owner April 21, 2026 13:55
@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  commerce_coordinator/apps/commercetools
  views.py
  commerce_coordinator/apps/commercetools/sub_messages
  tasks.py
  commerce_coordinator/apps/commercetools/tests
  test_views.py
  commerce_coordinator/apps/commercetools/tests/sub_messages
  test_tasks.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves dispatch of the “revoke line items” coordinator signal to the OrderReturnedView, rather than triggering it from within fulfill_order_returned_signal_task, so revocation is initiated directly from the CT “order returned” webhook handling path.

Changes:

  • Dispatch fulfill_order_returned_send_revoke_line_items_signal from OrderReturnedView after validating the incoming returned-order message.
  • Remove the revoke-signal dispatch from fulfill_order_returned_signal_task.
  • Update view and task tests to reflect the new dispatch location and expectations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
commerce_coordinator/apps/commercetools/views.py Adds revoke signal dispatch in OrderReturnedView.
commerce_coordinator/apps/commercetools/sub_messages/tasks.py Removes revoke signal dispatch from the returned-order Celery task.
commerce_coordinator/apps/commercetools/tests/test_views.py Updates OrderReturnedView tests to patch/assert the new revoke signal call.
commerce_coordinator/apps/commercetools/tests/sub_messages/test_tasks.py Removes revoke-signal assertions/patching from returned-order task tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +155 to +159
# revoke line items
fulfill_order_returned_send_revoke_line_items_signal.send_robust(
sender=self,
order_id=order_id,
return_items=return_items,
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

get_return_line_items() defaults to []. If a return message ever arrives with an empty returnInfo.items, this will still dispatch the revoke signal and enqueue a Celery task that immediately no-ops. Consider short-circuiting when return_items is empty (log + return 200) to reduce unnecessary queue traffic.

Copilot uses AI. Check for mistakes.
fulfill_order_returned_send_revoke_line_items_signal.send_robust(
sender=self,
order_id=order_id,
return_items=return_items,
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

For observability/correlation, consider passing message_id through this revoke signal as well (it’s available just above and is already passed to fulfill_order_returned_signal). The receiver can ignore unknown kwargs, but logs will then include the CT subscription message id.

Suggested change
return_items=return_items,
return_items=return_items,
message_id=message_id,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants