Skip to content

Prevent duplicate associations for the same workflow, event, and condition#7354

Merged
PasinduYeshan merged 6 commits intowso2:masterfrom
PasinduYeshan:fix/wf-self-reg
Sep 10, 2025
Merged

Prevent duplicate associations for the same workflow, event, and condition#7354
PasinduYeshan merged 6 commits intowso2:masterfrom
PasinduYeshan:fix/wf-self-reg

Conversation

@PasinduYeshan
Copy link
Contributor

@PasinduYeshan PasinduYeshan commented Sep 9, 2025

Proposed changes in this pull request

This pull request enhances the workflow association logic to prevent duplicate associations for the same workflow, event, and condition. The main update is the introduction of duplicate checks in both the association creation and update methods, alongside a new helper method to encapsulate this logic.

Duplicate association prevention:

  • Added a check in addAssociation to prevent creating a new association if one with the same workflow, event, and condition already exists. A WorkflowClientException is thrown if a duplicate is found.
  • Added a similar duplicate check in updateAssociation to prevent updating an association to a state that would duplicate an existing one.
  • Introduced a private helper method isDuplicateAssociation to encapsulate the logic for detecting duplicates, using CollectionUtils and Objects for null safety and comparison.

Related Issues

Merge Order

  1. Add SELF_REGISTER_USER operation type identity-api-server#988
  2. Prevent duplicate associations for the same workflow, event, and condition #7354
  3. Handle SELF_REGISTER_USER operation type in workflow wso2-extensions/identity-user-workflow#77
  4. Introduce SELF_REGISTER_USER operation type for workflow identity-apps#9055

When should this PR be merged

[Please describe any preconditions that need to be addressed before we
can merge this pull request.]

Follow up actions

[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]

Developer Checklist (Mandatory)

  • Complete the Developer Checklist in the related product-is issue to track any behavioral change or migration impact.

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly?

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place? There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
  • If this is a new feature or a significant change to an existing feature? has the manual testing spreadsheet been updated with instructions for manual testing?

Security

  • Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • Are all UI and API inputs run through forms or serializers?
  • Are all external inputs validated and sanitized appropriately?
  • Does all branching logic have a default case?
  • Does this solution handle outliers and edge cases gracefully?
  • Are all external communications secured and restricted to SSL?

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.

Copilot AI review requested due to automatic review settings September 9, 2025 09:35
Copy link
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 enhances the workflow association logic to prevent duplicate associations for the same workflow, event, and condition. The main changes include adding duplicate checks in both association creation and update methods, along with a new helper method to encapsulate this logic.

  • Added duplicate detection in addAssociation and updateAssociation methods to prevent creating/updating associations with the same workflow, event, and condition
  • Introduced a private helper method isDuplicateAssociation for reusable duplicate detection logic
  • Added comprehensive test coverage for the new duplicate detection functionality

Reviewed Changes

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

File Description
WorkflowManagementServiceImpl.java Added duplicate detection logic in addAssociation and updateAssociation methods, plus a new helper method isDuplicateAssociation
WorkflowManagementServiceImplTest.java Added extensive test cases for duplicate detection scenarios, edge cases, and validation

Copy link
Contributor

@wso2-engineering wso2-engineering bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
  • Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.

✅ Before merging this pull request:

  • Review all AI-generated comments for accuracy and relevance.
  • Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2
#### Log Improvement Suggestion No: 3
#### Log Improvement Suggestion No: 4
#### Log Improvement Suggestion No: 5
#### Log Improvement Suggestion No: 6
#### Log Improvement Suggestion No: 7
#### Log Improvement Suggestion No: 8
#### Log Improvement Suggestion No: 9
#### Log Improvement Suggestion No: 10
#### Log Improvement Suggestion No: 11
#### Log Improvement Suggestion No: 12
#### Log Improvement Suggestion No: 13

@PasinduYeshan
Copy link
Contributor Author

Add association:
image

Update association:
image

sadilchamishka
sadilchamishka previously approved these changes Sep 9, 2025
@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.77%. Comparing base (b9699eb) to head (38196bc).
⚠️ Report is 70 commits behind head on master.

Files with missing lines Patch % Lines
...ty/workflow/mgt/WorkflowManagementServiceImpl.java 77.27% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7354      +/-   ##
============================================
- Coverage     50.90%   50.77%   -0.14%     
- Complexity    18707    18771      +64     
============================================
  Files          2067     2073       +6     
  Lines        119498   120277     +779     
  Branches      24682    24866     +184     
============================================
+ Hits          60835    61073     +238     
- Misses        50801    51298     +497     
- Partials       7862     7906      +44     
Flag Coverage Δ
unit 34.98% <77.27%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/17578455316

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/17578455316
Status: failure

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/17593454769

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/17593454769
Status: failure

@sonarqubecloud
Copy link

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/17604010217

@PasinduYeshan
Copy link
Contributor Author

Integration Test Runner is passed for this:

image

@PasinduYeshan PasinduYeshan merged commit 9a9454f into wso2:master Sep 10, 2025
5 checks passed
@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/17604010217
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/17604010217

PasinduYeshan added a commit that referenced this pull request Sep 10, 2025
[Sync][master -> next][#7354]:  Prevent duplicate associations for the same workflow, event, and condition
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.

3 participants