Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/fix-multiple-message-start-events #1005

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented Feb 8, 2024

Fixes #1003

This updates MessageService to cancel all start events that do not match the start event that matches the trigger. This allows only the intended message instance to get created and allows SpiffWorkflow ignore any undesired start events that could cause it to not correctly return the waiting events.

Summary by CodeRabbit

  • New Features

    • Enhanced message service to handle processes with multiple message start events, improving the system's ability to orchestrate complex workflows.
  • Tests

    • Added tests to ensure messages correctly trigger the appropriate start events in processes with multiple message start points.

Copy link
Contributor

coderabbitai bot commented Feb 8, 2024

Walkthrough

The recent updates to the SpiffWorkflow backend and its tests introduce enhanced handling of BPMN message events, particularly focusing on processes with multiple message start events. These changes include the ability to start processes based on specific user messages, improved import functionalities, and the addition of a new method to cancel non-matching start events. Furthermore, a new BPMN process example and a test have been added to ensure that messages trigger the correct start event when multiple options are available, addressing issues related to process instance creation loops caused by message events.

Changes

File Path Change Summary
spiffworkflow-backend/src/.../message_service.py - Added imports for StartEventMixin and UserModel.
- Modified start_process_with_message to use user parameter.
- Added _cancel_non_matching_start_events method.
spiffworkflow-backend/tests/data/.../multiple-message-start-events.bpmn New BPMN process with multiple message start events for purchase and travel messages.
spiffworkflow-backend/tests/.../test_message_service.py Added test test_can_send_to_correct_start_event_if_there_are_multiple to ensure correct start event triggering.

Assessment against linked issues

Objective Addressed Explanation
#1003: Prevent multiple instance creation from a single message event
#1003: Ensure correct logic flow when a process is triggered by a message
#1003: Address looped creation of new instances with wrong logic

The code changes effectively address the primary concerns highlighted in issue #1003. The introduction of a method to cancel non-matching start events and the adjustment to start processes based on specific user messages directly tackle the issue of looped creation of instances and ensure that incoming messages trigger the correct process logic.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 886f1f5 and 39320e7.
Files selected for processing (3)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py (4 hunks)
  • spiffworkflow-backend/tests/data/multiple_message_start_events/multiple-message-start-events.bpmn (1 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_message_service.py (2 hunks)
Additional comments: 3
spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py (2)
  • 56-56: The start_process_with_message method now accepts a user parameter instead of message_instance. Ensure all calls to this method throughout the codebase have been updated accordingly.
Verification successful

The verification process confirms that all calls to the start_process_with_message method within the codebase have been updated to pass a user parameter, aligning with the changes mentioned. This includes both the implementation and unit tests, ensuring consistency with the updated method signature.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for calls to start_process_with_message and ensure they now pass a user parameter.
rg "start_process_with_message\(" --type py

Length of output: 486

* 127-141: The `_cancel_non_matching_start_events` method correctly cancels start events that do not match the intended start event. However, ensure that this logic does not inadvertently cancel events that should be triggered under valid conditions.
spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_message_service.py (1)
  • 190-209: The test test_can_send_to_correct_start_event_if_there_are_multiple correctly sets up a scenario to test the new functionality. Ensure that the test covers all relevant cases, including negative scenarios where a message should not trigger a start event.

@jasquat jasquat merged commit 4b2fbd8 into main Feb 8, 2024
19 checks passed
@jasquat jasquat deleted the feature/fix-multiple-message-start-events branch February 8, 2024 19:55
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.

messages cause more than one instance to be kicked off
1 participant