Bindu icon indicating copy to clipboard operation
Bindu copied to clipboard

[Bug]: Add Error Handling for OAuth Provider Failures in Frontend

Open Suvam-paul145 opened this issue 9 months ago • 4 comments

Summary:

  • Wrap OAuth provider calls in try/catch and return a structured error when the provider is unreachable.
  • Show a user-friendly message in the UI when sign in fails due to provider unavailability.
  • Add unit tests for the failure path and an e2e test for UI behavior.

Files changed:

  • frontend/src/lib/server/auth.ts
  • frontend/src/components/SignInButton.tsx (or equivalent)
  • tests/unit/auth.spec.ts
  • tests/e2e/auth-provider-failure.spec.ts

Why:

  • Prevents frontend crashes/hangs when third-party auth services are down.
  • Improves UX and observability.

How tested:

  • Unit tests added for provider failure and 5xx responses.
  • Playwright e2e simulating provider downtime and asserting the error toast.

Notes:

  • Logging added but no sensitive data is recorded.
  • Telemetry hook included; configure Sentry/monitoring DSN as needed.

Checklist:

  • [x] Wrap provider calls in try/catch and return structured error response
  • [x] Return HTTP 502 with OAUTH_PROVIDER_UNAVAILABLE / OAUTH_PROVIDER_ERROR
  • [x] Show readable error message in UI
  • [x] Add unit tests
  • [x] Add e2e test
  • [x] Add telemetry/logging statement

Suvam-paul145 avatar Feb 27 '26 12:02 Suvam-paul145

@Suvam-paul145 where we are now?

raahulrahl avatar Mar 06 '26 11:03 raahulrahl

@raahulrahl please add apertre 3.0 and difficulty label

Suvam-paul145 avatar Mar 06 '26 13:03 Suvam-paul145

@raahulrahl please add apertre 3.0 and difficulty label before merge

Suvam-paul145 avatar Mar 07 '26 13:03 Suvam-paul145

The core issue is that unhandled promise rejections from OAuth provider calls (likely in frontend/src/lib/server/auth.ts) can cause the server to hang or return unformatted 5xx responses, leaving the UI in an indeterminate loading state. Without a try/catch boundary, a network timeout or DNS failure to the provider propagates as an uncaught exception rather than a structured response, which is why the frontend crashes or hangs instead of surfacing a recoverable error. Returning HTTP 502 with OAUTH_PROVIDER_UNAVAILABLE is the right signal here — it correctly distinguishes a third-party dependency failure from an internal server error (500), and gives the SignInButton component a clear contract to display the error toast. Worth confirming the error boundary in the UI also handles the case where the fetch to your own auth endpoint times out client-side, since a 502 may never arrive if the server itself is stalled waiting on the provider.

JiwaniZakir avatar Apr 04 '26 20:04 JiwaniZakir