fix: login Snackbar Shows Undefined for Invalid Credentials#1092
Open
DevipriyaS17 wants to merge 3 commits into
Open
fix: login Snackbar Shows Undefined for Invalid Credentials#1092DevipriyaS17 wants to merge 3 commits into
DevipriyaS17 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1092 +/- ##
==========================================
+ Coverage 43.44% 43.49% +0.05%
==========================================
Files 143 143
Lines 13621 13621
==========================================
+ Hits 5917 5924 +7
+ Misses 7143 7135 -8
- Partials 561 562 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #994 by ensuring the v1 login endpoint returns a user-friendly error message when invalid credentials are submitted, preventing the UI snackbar from displaying Undefined.
Changes:
- Update
POST /api/v1/authorizeinvalid-credentials (401) response to include amessagefield with a user-friendly string. - Add a regression test verifying the 401 response includes both
errorandmessage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/controller/httpapi/v1/login.go | Adds message to the 401 invalid-credentials JSON response. |
| internal/controller/httpapi/v1/login_test.go | Adds a test to assert the invalid-credentials response includes the expected message. |
nbmaiti
approved these changes
Jul 2, 2026
sudhir-intc
reviewed
Jul 3, 2026
| func (lr LoginRoute) handleBasicAuth(creds dto.Credentials, c *gin.Context) { | ||
| if creds.Username != lr.Config.AdminUsername || creds.Password != lr.Config.AdminPassword { | ||
| c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials"}) | ||
| c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect username or password"}) |
Contributor
There was a problem hiding this comment.
Suggested change
| c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect username or password"}) | |
| c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect Username and/or Password!"}) |
Contributor
There was a problem hiding this comment.
Have the error message consistent with MPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes issue #994 where the login snackbar showed Undefined when invalid username/password was submitted.
Problem
When POST /api/v1/authorize returned 401 for bad credentials, the frontend expected a message field but did not receive a clear user-facing value, which resulted in an unclear snackbar message.
Root Cause
The invalid-credentials response did not include a user-friendly message aligned with frontend expectations.
Expected behavior
When the username or password is incorrect, the snackbar should show a clear message such as Incorrect username or password.
Screenshots
