fix: use error detail for login credential error messages#2794
Open
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
Open
fix: use error detail for login credential error messages#2794hztBUAA wants to merge 1 commit intoChainlit:mainfrom
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
Conversation
The login form displayed the wrong error message for incorrect credentials because it read error.message (HTTP status text like "Unauthorized") instead of error.detail (the actual error reason like "credentialsSignin"). Updated the catch block in LoginForm to check for ClientError.detail first, falling back to Error.message when detail is not available. Fixes Chainlit#2787
Collaborator
|
Does this close/address #2787 ? |
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.
Summary
Fixes #2787
The login form displayed the wrong error message for incorrect credentials because it read
error.message(HTTP status text like "Unauthorized") instead oferror.detail(the actual error reason like "credentialsSignin").Changes
ClientErrorfrom@chainlit/react-clientinLoginForm.tsxClientError.detailfirst, which contains the meaningful error reason (e.g., "credentialsSignin")Error.messagewhendetailis not available, preserving backward compatibilityHow it works
When the
/loginendpoint returns an error, thefetchwrapper inapi/index.tsxcreates aClientErrorwith:message= HTTP status text (e.g., "Unauthorized")detail= parsed response body detail (e.g., "credentialsSignin")Previously,
LoginFormusederr.messagefor the translation key lookup (auth.login.errors.unauthorized), which didn't match any translation. Now it useserr.detail(auth.login.errors.credentialssignin), which correctly maps to the intended error message.Test Plan
error.messageas beforeerror.messageSummary by cubic
Fixes #2787. Use ClientError.detail in LoginForm so invalid credential attempts display the correct translated error, falling back to Error.message when detail is missing.
Written for commit 18a8187. Summary will update on new commits.