Skip to content

fix(auth): distinguish OAuth access denials - #3010

Open
postoso wants to merge 1 commit into
Chainlit:fix/oauth-error-ux-1273from
postoso:fix/oauth-access-denied-2956
Open

fix(auth): distinguish OAuth access denials#3010
postoso wants to merge 1 commit into
Chainlit:fix/oauth-error-ux-1273from
postoso:fix/oauth-access-denied-2956

Conversation

@postoso

@postoso postoso commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • Route the exact provider error access_denied to oauthAccessDenied in both OAuth callback handlers.
  • Keep other provider errors on the existing oauthSignin fallback.
  • Reuse the 23 locale strings from my closed fix(auth): distinct login message for OAuth access_denied #2970 under the camelCase key.
  • Cover both redirect variants, locale presence, and both rendered login messages.

Testing

  • uv run --project backend pytest backend/tests/test_server.py backend/tests/test_translations.py (99 passed)
  • pnpm exec cypress run --spec cypress/e2e/oauth_auth/spec.cy.ts --browser electron (4 passed)
  • pre-commit hooks, Ruff, type-checking, and Prettier passed

Depends on #2955. Addresses #2956.


Summary by cubic

Show a specific, localized login message when OAuth is cancelled or access is denied, and keep the generic message for other failures. Updates both OAuth callback paths and all locales to match Linear #2956.

  • Bug Fixes
    • Map provider access_denied to oauthAccessDenied in oauth_callback and oauth_azure_hf_callback; keep oauthSignin for other errors.
    • Add oauthAccessDenied to 23 locale files.
    • Expand tests: unit tests for redirect behavior and translation presence; Cypress test for the rendered alert message.

Written for commit 923e175. Summary will update on new commits.

Review in cubic

Route explicit access_denied provider responses to a dedicated localized login message while preserving the generic fallback for other OAuth failures. Reuse the 23 locale strings from Chainlit#2970 and cover both callback variants and rendered messages.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. auth Pertaining to authentication. backend Pertains to the Python backend. e2e-tests Has E2E tests labels Aug 3, 2026
@dosubot dosubot Bot added translation Translation or localisation of strings. unit-tests Has unit tests. labels Aug 3, 2026

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 27 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/chainlit/server.py">

<violation number="1" location="backend/chainlit/server.py:674">
P3: OAuth provider-error mapping is now duplicated in both callback handlers, which can drift if one flow is updated later and the other is missed. A shared helper for mapping provider errors to login error keys would keep both redirect variants consistent.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

if error:
logger.warning("OAuth provider %s returned error: %s", provider_id, error)
return _get_oauth_redirect_error(request, "oauthSignin")
error_key = "oauthAccessDenied" if error == "access_denied" else "oauthSignin"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: OAuth provider-error mapping is now duplicated in both callback handlers, which can drift if one flow is updated later and the other is missed. A shared helper for mapping provider errors to login error keys would keep both redirect variants consistent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/chainlit/server.py, line 674:

<comment>OAuth provider-error mapping is now duplicated in both callback handlers, which can drift if one flow is updated later and the other is missed. A shared helper for mapping provider errors to login error keys would keep both redirect variants consistent.</comment>

<file context>
@@ -671,7 +671,8 @@ async def oauth_callback(
     if error:
         logger.warning("OAuth provider %s returned error: %s", provider_id, error)
-        return _get_oauth_redirect_error(request, "oauthSignin")
+        error_key = "oauthAccessDenied" if error == "access_denied" else "oauthSignin"
+        return _get_oauth_redirect_error(request, error_key)
 
</file context>

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

Labels

auth Pertaining to authentication. backend Pertains to the Python backend. e2e-tests Has E2E tests size:XS This PR changes 0-9 lines, ignoring generated files. translation Translation or localisation of strings. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant