-
Notifications
You must be signed in to change notification settings - Fork 239
Fix Event Not Firing in Flows. #1088
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
Fix Event Not Firing in Flows. #1088
Conversation
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Show resolved
Hide resolved
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Show resolved
Hide resolved
...ecovery/src/main/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListener.java
Outdated
Show resolved
Hide resolved
...ecovery/src/main/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListener.java
Outdated
Show resolved
Hide resolved
...ery/src/test/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListenerTest.java
Show resolved
Hide resolved
...ery/src/test/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListenerTest.java
Show resolved
Hide resolved
There was a problem hiding this 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
- 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.
There was a problem hiding this 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 pull request refactors the event publishing logic in user registration and recovery flows to fix issues where events were not firing correctly. The changes standardize event publishing across handlers, improve naming consistency, and enhance error handling.
Changes:
- Introduced a new
publishEventmethod inFlowRegistrationCompletionHandlerto handle USER_REGISTRATION_SUCCESS events with proper conditions - Refactored
FlowCompletionListener.publishEventto accept an event name parameter and removed the overloaded variant, consolidating event publishing logic - Renamed variables from
domainNametouserStoreDomainandisNotificationInternallyManagetoisNotificationInternallyManagedfor consistency - Updated test cases to reflect new event publishing behavior with correct assertion counts
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java | Added new publishEvent method, improved variable naming (domainName→userStoreDomain), and implemented logic to publish USER_REGISTRATION_SUCCESS event when notification channel is verified or confirmation is disabled |
| components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListener.java | Refactored publishEvent to take event name parameter, removed old overload, added separate error handling for IdentityEventException, and updated calls to use new signature with POST_ADD_NEW_PASSWORD event |
| components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/listener/FlowCompletionListenerTest.java | Updated test expectations to verify correct event publishing counts, added new test cases for various scenarios (SMS channel, external channel, event exceptions), and removed obsolete helper methods |
| components/org.wso2.carbon.identity.recovery/src/test/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandlerTest.java | Added comprehensive test coverage for new event publishing logic including tests for account lock scenarios, notification channel verification, externally managed notifications, and event exception handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1088 +/- ##
============================================
+ Coverage 54.35% 54.61% +0.26%
- Complexity 3158 3187 +29
============================================
Files 316 316
Lines 21650 21675 +25
Branches 4173 4178 +5
============================================
+ Hits 11768 11838 +70
+ Misses 8376 8336 -40
+ Partials 1506 1501 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Verification Flow 1: (Self registration without in flow Notification channel Verification)
NormalScenario.mp4Verification Flow 2: (Self registration without in flow Notification channel Verification + account Lock)
AccountLockScenario.mp4Verification Flow 3: (Self registration without in flow Notification channel Verification + account confirm)
Verification Flow 4: (Self Registration + workflow)
WorkFlowEngaged.mp4Verification Flow 5: (Self Registration + workflow + account lock)
AccountLockOnWorkFlow.mp4Verification Flow 6: (Self registration without in flow Notification channel Verification)
VerifeidNotificationChannelScenario.mp4Verification Flow 7: (Self Registration with federated IDP (Email channel is considered verified)
FederatedScenario.mp4Verification Flow 8: (Password Reset)
credentialUpdateEventNotFired.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Outdated
Show resolved
Hide resolved
|
PR builder started |
|
PR builder completed |
jenkins-is-staging
left a comment
There was a problem hiding this 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/21164595937
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Outdated
Show resolved
Hide resolved
e4a1b3b to
278c229
Compare
|
Note For the Scenario where Self registration is enabled with email confirmation without account locking As discussed offline with @ashanthamara, this change currently results in two registrationSuccess events being fired. The event triggered during the confirmation step should be removed, as the event introduced here represents the correct and intended registrationSuccess event. Will be tracked with wso2/product-is#26567 |
|
PR builder started |
|
PR builder completed |
jenkins-is-staging
left a comment
There was a problem hiding this 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/21172101859
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/wso2/carbon/identity/recovery/handler/FlowRegistrationCompletionHandler.java
Outdated
Show resolved
Hide resolved
| } | ||
| publishEvent(user, confirmationCode, recoveryScenario); | ||
| } catch (UserStoreException | IdentityRecoveryException | IdentityEventException | FlowMgtServerException e) { | ||
| publishEvent(user, confirmationCode, recoveryScenario, IdentityEventConstants.Event.POST_ADD_NEW_PASSWORD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure whether the POST_ADD_NEW_PASSWORD correct event name for this case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, According to webhook implementations (https://github.com/wso2-extensions/identity-webhook-event-handlers/blob/4947f1747783207fe2b3b2546f5b068d35403eca/components/org.wso2.identity.webhook.common.event.handler/src/main/java/org/wso2/identity/webhook/common/event/handler/internal/handler/RegistrationEventHookHandler.java#L167) this is captured from webhook side and converted to registrationSuccess event.
Please refert to below comment for verification on event publishing on new invited user registration flow.
#1088 (comment)
278c229 to
98dc1cc
Compare
|
Verification on correct event publishing on invited user reg flow. Screen.Recording.2026-01-21.at.09.08.32.mp4 |
|
PR builder started |
|
PR builder completed |
jenkins-is-staging
left a comment
There was a problem hiding this 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/21197098117
Related Issues
registrationSuccessevent triggered when workflows are engaged in self registration flow. wso2/product-is#26562credentialUpdatedevent triggered when the user resets the password with a new Password recovery flow. wso2/product-is#26560registrationSuccessevent triggered when user self register with basic self register flow (basic details + email otp) wso2/product-is#26561This pull request refactors and improves the event publishing logic in the user registration and recovery flow handlers. The main changes include standardizing how events are published, improving naming consistency, and ensuring correct event triggers during registration and recovery scenarios. The updates also enhance error handling and code readability.
Event Publishing Refactor:
publishEventmethod inFlowRegistrationCompletionHandler.javato standardize event publishing, including all relevant user and event properties. This replaces previous ad-hoc event publishing logic.handleEventto use the newpublishEventmethod and ensure events are only published under the correct conditions, such as notification channel verification and configuration checks. [1] [2]Naming and Consistency Improvements:
domainNametouserStoreDomain,isNotificationInternallyManagetoisNotificationInternallyManaged) and ensured consistent usage throughout the handlers. [1] [2] [3]Listener Event Handling Updates:
FlowCompletionListener.javato use a single, parameterizedpublishEventmethod, ensuring consistent event names and error handling across registration, invitation, and password recovery flows. [1] [2] [3] [4] [5]Error Handling Enhancements:
Code Cleanup: