PII issues fixes with backward compatibility for booking service [MOSIP-44379]#1091
PII issues fixes with backward compatibility for booking service [MOSIP-44379]#1091GOKULRAJ136 wants to merge 9 commits intomosip:developfrom
Conversation
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
WalkthroughUpdates kernel versions and adds canonical user-ID resolution in BookingServiceUtil with a PII backward-compatibility flag, new configuration properties, and unit tests covering canonical resolution, fallback, and strict modes. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller (service flow)
participant BookingUtil as BookingServiceUtil
participant UserSvc as UserDetailsService
participant Auth as AuthContext
Caller->>Auth: obtain rawIdentifier
Caller->>BookingUtil: bookingEntitySetter(rawIdentifier,...)
BookingUtil->>UserSvc: findOrCreateByIdentifier(rawIdentifier)
alt mapping succeeds
UserSvc-->>BookingUtil: UserDetails (canonicalId)
BookingUtil-->>BookingUtil: maskIdentifier(rawIdentifier) for logs
BookingUtil-->>Caller: set crBy = canonicalId
else mapping fails
alt piiBackwardCompatibility == true
BookingUtil-->>Caller: set crBy = rawIdentifier
else piiBackwardCompatibility == false
BookingUtil-->>Caller: throw AppointmentBookingFailedException
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
pre-registration-booking-service/pom.xmlpre-registration-booking-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.javapre-registration-booking-service/src/main/resources/bootstrap.propertiespre-registration-booking-service/src/test/java/io/mosip/preregistration/booking/test/service/util/BookingServiceUtilTest.javapre-registration-booking-service/src/test/resources/application.properties
...-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.java
Show resolved
Hide resolved
Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
pre-registration-booking-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.java (1)
558-575:⚠️ Potential issue | 🟠 MajorGuard against blank raw fallback in backward-compatibility mode.
On Line [568]-Line [571], fallback returns
userIdeven when it may be null/blank, which can still persist an unattributablecrBy. Fail fast unless a non-blank identifier is available.Proposed fix
private String resolveEffectiveCrBy(String userId) { + if (userId == null || userId.isBlank()) { + throw new AppointmentBookingFailedException( + ErrorCodes.PRG_BOOK_RCI_005.getCode(), + ErrorMessages.APPOINTMENT_BOOKING_FAILED.getMessage()); + } try { UserDetails userDetail = userDetailsService.findOrCreateByIdentifier(userId); if (userDetail != null && userDetail.getUserId() != null) { return userDetail.getUserId().toString(); } } catch (Exception ex) { log.warn("sessionId", "idType", "id", "Failed to resolve canonical user id for booking: " + maskIdentifier(userId)); } - if (piiBackwardCompatibility) { + if (piiBackwardCompatibility) { log.warn("sessionId", "idType", "id", "Falling back to raw identifier for booking due to backward-compatibility mode"); return userId; } throw new AppointmentBookingFailedException(ErrorCodes.PRG_BOOK_RCI_005.getCode(), ErrorMessages.APPOINTMENT_BOOKING_FAILED.getMessage()); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pre-registration-booking-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.java` around lines 558 - 575, The resolveEffectiveCrBy method currently falls back to returning userId when piiBackwardCompatibility is true even if userId is null/blank; update resolveEffectiveCrBy to validate that the raw identifier is non-blank before returning it (use a String non-blank check or StringUtils.isBlank/hasText), log a clear warning (including maskIdentifier(userId)) when the raw id is blank, and if blank throw AppointmentBookingFailedException with ErrorCodes.PRG_BOOK_RCI_005 and ErrorMessages.APPOINTMENT_BOOKING_FAILED; keep the existing catch block and masking behavior but ensure the fallback only returns a non-empty identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@pre-registration-booking-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.java`:
- Around line 558-575: The resolveEffectiveCrBy method currently falls back to
returning userId when piiBackwardCompatibility is true even if userId is
null/blank; update resolveEffectiveCrBy to validate that the raw identifier is
non-blank before returning it (use a String non-blank check or
StringUtils.isBlank/hasText), log a clear warning (including
maskIdentifier(userId)) when the raw id is blank, and if blank throw
AppointmentBookingFailedException with ErrorCodes.PRG_BOOK_RCI_005 and
ErrorMessages.APPOINTMENT_BOOKING_FAILED; keep the existing catch block and
masking behavior but ensure the fallback only returns a non-empty identifier.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pre-registration-booking-service/src/main/java/io/mosip/preregistration/booking/service/util/BookingServiceUtil.javapre-registration-booking-service/src/test/java/io/mosip/preregistration/booking/test/service/util/BookingServiceUtilTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
- pre-registration-booking-service/src/test/java/io/mosip/preregistration/booking/test/service/util/BookingServiceUtilTest.java
Summary by CodeRabbit
Chores
New Features
Tests