Skip to content

Conversation

@Rakshithasai123
Copy link

@Rakshithasai123 Rakshithasai123 commented Nov 18, 2025

RCF-373

Summary by CodeRabbit

  • New Features

    • Added multilingual server unavailability messaging to inform users when authentication services are unreachable, supported across 7 languages.
  • Bug Fixes

    • Improved error handling to properly communicate authentication server connectivity issues instead of generic error messages.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

Error handling for authentication server failures was updated: a specific error condition now maps to a dedicated error code, triggering a localized "server unreachable" message. Localization entries for this message were added across six languages, and UI error display logic now intercepts and shows this message for specific server-related error codes.

Changes

Cohort / File(s) Summary
Authentication API error mapping
android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java
Changed error code mapping for "Invalid Request" from REG_INVALID_REQUEST to REG_AUTH_SERVER_DOWN
Localization entries for server unreachable
assets/l10n/app_en.arb, assets/l10n/app_ar.arb, assets/l10n/app_fr.arb, assets/l10n/app_hi.arb, assets/l10n/app_kn.arb, assets/l10n/app_ta.arb
Added server_unreachable translation key with localized messages across six languages; adjusted syntax with trailing commas
Login page error display
lib/ui/login_page.dart
Added early error handling in _showErrorInSnackbar to intercept REG_AUTH_SERVER_DOWN, KER-SYN-AUTH-001, and Invalid Request errors and display server_unreachable message

Sequence Diagram

sequenceDiagram
    participant User
    participant LoginPage
    participant AuthApi
    
    User->>LoginPage: Attempts authentication
    LoginPage->>AuthApi: Calls authentication
    AuthApi->>AuthApi: Invalid request detected
    AuthApi-->>LoginPage: Returns error with<br/>REG_AUTH_SERVER_DOWN code
    LoginPage->>LoginPage: _showErrorInSnackbar checks<br/>error code/message
    Note over LoginPage: Matches REG_AUTH_SERVER_DOWN<br/>or KER-SYN-AUTH-001<br/>or Invalid Request?
    LoginPage->>LoginPage: Fetch server_unreachable<br/>localized message
    LoginPage-->>User: Display snackbar:<br/>"Authentication server<br/>unreachable. Please try<br/>again later."
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • AuthenticationApi.java: Single-line error code mapping change; straightforward and low-risk
  • Localization files (.arb): Six repetitive, identical pattern additions across languages with minor formatting adjustments; low cognitive load due to uniformity
  • login_page.dart: Conditional logic addition to intercept specific error codes; clear intent and limited scope

Poem

🐰 Hops through the code with glee,
Server errors now speak so free,
Six tongues say "please wait, friend,"
When auth roads reach their end. 🌍✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Incorrect error message on login screen' accurately reflects the main change: correcting error message handling and display in the login page when authentication server errors occur.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f46caa and 4a6edda.

📒 Files selected for processing (8)
  • android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java (1 hunks)
  • assets/l10n/app_ar.arb (1 hunks)
  • assets/l10n/app_en.arb (1 hunks)
  • assets/l10n/app_fr.arb (1 hunks)
  • assets/l10n/app_hi.arb (1 hunks)
  • assets/l10n/app_kn.arb (1 hunks)
  • assets/l10n/app_ta.arb (1 hunks)
  • lib/ui/login_page.dart (1 hunks)
🔇 Additional comments (7)
assets/l10n/app_kn.arb (1)

335-336: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with Kannada translation and the trailing comma adjustment for valid JSON syntax are correct.

assets/l10n/app_ar.arb (1)

335-336: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with Arabic translation and the trailing comma adjustment are correct.

assets/l10n/app_en.arb (1)

335-336: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with English translation and the trailing comma adjustment are correct.

assets/l10n/app_fr.arb (1)

335-336: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with French translation and the trailing comma adjustment are correct.

assets/l10n/app_ta.arb (1)

344-345: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with Tamil translation and the trailing comma adjustment are correct.

assets/l10n/app_hi.arb (1)

335-336: LGTM: Localization entry added correctly.

The addition of the server_unreachable key with Hindi translation and the trailing comma adjustment are correct.

android/app/src/main/java/io/mosip/registration_client/api_services/AuthenticationApi.java (1)

133-139: Verify the authentication server's actual error messages when it's unreachable.

The concern raised is valid. The mapping of "Invalid Request" to REG_AUTH_SERVER_DOWN appears semantically inconsistent:

  • "Invalid Request" typically indicates a malformed or client-side validation error (consistent with its use in @notblank validation annotations throughout the codebase)
  • REG_AUTH_SERVER_DOWN semantically suggests server unavailability
  • A separate error code REG_INVALID_REQUEST exists elsewhere (line 165), indicating two distinct error types are expected

From the codebase, I cannot confirm whether the authentication server actually returns "Invalid Request" when unreachable or if this represents a different error condition. You should verify the server's actual error responses to ensure the mapping is correct, or consider using the existing REG_INVALID_REQUEST code if this represents invalid request format rather than server unavailability.

Comment on lines +357 to +360
if (errorMsg == "REG_AUTH_SERVER_DOWN" || errorMsg == "KER-SYN-AUTH-001" || errorMsg == "Invalid Request") {
_showInSnackBar(appLocalizations.server_unreachable);
return;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potential redundancy and fragile string comparison in error handling.

This code checks for three conditions: REG_AUTH_SERVER_DOWN, KER-SYN-AUTH-001, and "Invalid Request". Based on the changes in AuthenticationApi.java, the server message "Invalid Request" is now mapped to REG_AUTH_SERVER_DOWN before reaching the UI. This raises two concerns:

  1. Redundancy: Checking for both the error code (REG_AUTH_SERVER_DOWN) and the raw message ("Invalid Request") suggests either defensive programming or confusion about the error flow. If they're both needed, please clarify the different scenarios where each condition is true.

  2. Fragile string comparison: Directly comparing errorMsg == "Invalid Request" is fragile—if the server message changes or gets localized, this will silently fail. Error codes should be used consistently for error handling.

Recommendation: Consider adding REG_AUTH_SERVER_DOWN and KER-SYN-AUTH-001 to the errors mapping in the ARB files (line 308) for consistency, rather than handling them as special cases here. This would align with how other error codes are handled.

// Instead of special-case handling, consider:
// 1. Add to errors mapping in ARB files:
// "errors": "{messages, select, ..., REG_AUTH_SERVER_DOWN{Authentication server unreachable. Please try again later}, KER-SYN-AUTH-001{Authentication server unreachable. Please try again later}, ...}"
// 
// 2. Remove the special case and let the existing logic handle it:
// String snackbarText = appLocalizations.errors(errorMsg);
// if (snackbarText == "Some error occurred!") {
//   snackbarText = errorMsg;
// }
// _showInSnackBar(snackbarText);
🤖 Prompt for AI Agents
In lib/ui/login_page.dart around lines 357 to 360, the code special-cases
errorMsg values ("REG_AUTH_SERVER_DOWN", "KER-SYN-AUTH-001", and the raw
"Invalid Request") which is redundant and fragile; update the ARB error mapping
(around line 308) to include REG_AUTH_SERVER_DOWN and KER-SYN-AUTH-001 with the
desired user-facing text, remove the special-case if-block here, and let
appLocalizations.errors(errorMsg) drive the snackbar text; if you must keep both
checks, add a brief comment explaining the distinct server/client scenarios and
replace the raw-string comparison with a check against a centralized constant or
enum to avoid fragile literal matching.

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.

1 participant