Skip to content

Comments

fix: use error detail for login credential error messages#2794

Open
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
hztBUAA:fix/login-error-message
Open

fix: use error detail for login credential error messages#2794
hztBUAA wants to merge 1 commit intoChainlit:mainfrom
hztBUAA:fix/login-error-message

Conversation

@hztBUAA
Copy link

@hztBUAA hztBUAA commented Feb 20, 2026

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 of error.detail (the actual error reason like "credentialsSignin").

Changes

  • Import ClientError from @chainlit/react-client in LoginForm.tsx
  • Updated the catch block to check for ClientError.detail first, which contains the meaningful error reason (e.g., "credentialsSignin")
  • Falls back to Error.message when detail is not available, preserving backward compatibility

How it works

When the /login endpoint returns an error, the fetch wrapper in api/index.tsx creates a ClientError with:

  • message = HTTP status text (e.g., "Unauthorized")
  • detail = parsed response body detail (e.g., "credentialsSignin")

Previously, LoginForm used err.message for the translation key lookup (auth.login.errors.unauthorized), which didn't match any translation. Now it uses err.detail (auth.login.errors.credentialssignin), which correctly maps to the intended error message.

Test Plan

  • Enter incorrect credentials on the login screen -> proper translated error message is displayed
  • Non-ClientError exceptions still display error.message as before
  • ClientError without detail falls back to error.message

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

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
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. auth Pertaining to authentication. labels Feb 20, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@dokterbob
Copy link
Collaborator

Does this close/address #2787 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Pertaining to authentication. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: On Logging-Screen for password authentication, the error message for incorrect credentials is missing or just the default.

2 participants