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

Distinguishes OAuth access denials to show a specific, localized login message, meeting Linear #2956. Previously all provider errors showed the generic message; now access_denied maps to a dedicated message while other errors keep the generic fallback.

  • Routes access_denied to oauthAccessDenied in both oauth_callback and oauth_azure_hf_callback; other errors still use oauthSignin.
  • Adds oauthAccessDenied to 23 locale files and tests presence across all locales.
  • Expands tests to cover access-denied vs other errors for both callbacks, redirect status codes (302/303), and the rendered alert on the login page.

Written for commit c1d3ca1. Summary will update on new commits.

Review in cubic

@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>

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>
@dokterbob
dokterbob force-pushed the fix/oauth-access-denied-2956 branch from 923e175 to c1d3ca1 Compare August 17, 2026 17:20
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