Skip to content

Fix: Multiple Error Message Popups on Login Failure (HWC UI) #125#265

Open
megha1807 wants to merge 1 commit intoPSMRI:mainfrom
megha1807:fix/multiple-error-popups-login
Open

Fix: Multiple Error Message Popups on Login Failure (HWC UI) #125#265
megha1807 wants to merge 1 commit intoPSMRI:mainfrom
megha1807:fix/multiple-error-popups-login

Conversation

@megha1807
Copy link
Copy Markdown

@megha1807 megha1807 commented Mar 24, 2026

Problem

Fixes #125

When login fails, two error popups were displayed:

  1. One from the else block on session conflict cancel (with incorrect message)
  2. One from the err callback with a raw error object (meaningless message)

Changes Made

  • Removed duplicate confirmationService.alert() from the session conflict cancel block
  • Replaced raw err object in error callback with a meaningful fallback error message

Expected Behaviour

  • Single error popup shown on login failure
  • Clear, meaningful error message displayed to the user

Summary by CodeRabbit

  • Bug Fixes
    • Improved login error handling to display user-friendly messages when authentication fails, instead of showing technical error details
    • Refined error confirmation behavior during the authentication process

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Updated error handling in the login component to extract and display user-friendly error messages from the authentication service response, with fallback chains for missing error details, rather than alerting raw error objects.

Changes

Cohort / File(s) Summary
Login Error Handling
src/app/user-login/login/login.component.ts
Improved error message extraction in the login subscription callback by deriving a descriptive message from err?.error?.errorMessage with fallbacks to err?.message and a default "Login failed…" message. Removed an extraneous alert call in the logout confirmation branch.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through login gates,
Where error messages once held fate,
Now friendly text does softly show,
No cryptic codes to cause us woe!
Better fallbacks, clearer sight—
The login flow shines ever bright! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses a bug fix for login error handling, but the linked issue #125 focuses on HWC-to-AAM migration with documentation and reference updates, which differs from the bug fix scope. Verify that this bug fix aligns with issue #125 objectives or link to the correct issue if this is a separate bug fix not covered by the migration scope.
Out of Scope Changes check ⚠️ Warning The changes focus solely on fixing duplicate error popups in login error handling, which is a targeted bug fix unrelated to the HWC-to-AAM migration objectives mentioned in issue #125. Clarify whether this bug fix is part of the broader AAM migration effort or if it should be tracked under a separate issue distinct from #125.
✅ 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 clearly and specifically describes the main change: fixing multiple error message popups on login failure, with a direct reference to issue #125.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
src/app/user-login/login/login.component.ts (1)

276-283: Good fix for displaying meaningful error messages.

The fallback chain correctly extracts a user-friendly message instead of alerting the raw error object. The approach handles the common cases:

  • API error response body (err.error.errorMessage)
  • Standard Error message (err.message)
  • Static fallback for unexpected error shapes

For consistency, consider aligning with the existing getErrorMessage() pattern in http-interceptor.service.ts (lines 152-184), which also handles edge cases like string errors and error.error as a string. You could either:

  1. Extract a shared utility function, or
  2. Add similar defensive checks here:
♻️ Optional: More defensive error extraction
          (err) => {
            this.resetCaptcha();
-           const errorMessage =
-               err?.error?.errorMessage ||
-               err?.message ||
-               'Login failed. Please check your credentials and try again.';
+           let errorMessage = 'Login failed. Please check your credentials and try again.';
+           if (typeof err === 'string' && err.trim()) {
+             errorMessage = err;
+           } else if (err && typeof err === 'object') {
+             errorMessage =
+               err.error?.errorMessage ||
+               err.message ||
+               (typeof err.error === 'string' ? err.error : errorMessage);
+           }
            this.confirmationService.alert(errorMessage, 'error');
          },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/user-login/login/login.component.ts` around lines 276 - 283, The
current error extraction in the login handler uses err?.error?.errorMessage ||
err?.message || fallback; update it to the same defensive logic as
getErrorMessage() from http-interceptor.service.ts by either calling that shared
utility or replicating its checks: handle cases where err.error is a string,
where err itself is a string, and where nested error shapes exist before falling
back to 'Login failed...'; apply this change inside the login component's error
callback (the handler that calls this.resetCaptcha() and
this.confirmationService.alert()) so confirmationService.alert receives a
normalized string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/app/user-login/login/login.component.ts`:
- Around line 276-283: The current error extraction in the login handler uses
err?.error?.errorMessage || err?.message || fallback; update it to the same
defensive logic as getErrorMessage() from http-interceptor.service.ts by either
calling that shared utility or replicating its checks: handle cases where
err.error is a string, where err itself is a string, and where nested error
shapes exist before falling back to 'Login failed...'; apply this change inside
the login component's error callback (the handler that calls this.resetCaptcha()
and this.confirmationService.alert()) so confirmationService.alert receives a
normalized string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: baed2c07-6a8f-4cc5-b71a-049a64c69925

📥 Commits

Reviewing files that changed from the base of the PR and between b742399 and 17c5238.

📒 Files selected for processing (1)
  • src/app/user-login/login/login.component.ts

@megha1807
Copy link
Copy Markdown
Author

Hello @snehar-nd,
I have submitted a PR to fix the multiple error message popups on the login screen.

Changes made:

  • Removed duplicate confirmationService.alert() from the session conflict cancel block
  • Replaced raw err object with a meaningful fallback error message in the error callback

Please review when you get a chance. Thank you!

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