Bindu icon indicating copy to clipboard operation
Bindu copied to clipboard

OAuth provider failures were not handled properly in the frontend, causing unclear errors and broken login behavior.

Open Suvam-paul145 opened this issue 8 months ago • 0 comments

  • Why it matters: Users experienced failed sign-ins without feedback, and the app risked crashes or hanging when providers were down.
  • What changed: Added try/catch handling, structured 502 error responses, UI toast messaging, fixed sign-in component, and added unit + e2e tests.
  • What did NOT change (scope boundary): No changes to core auth logic or successful login flow.

Change Type (select all that apply)

  • [x] Bug fix
  • [ ] Feature
  • [x] Refactor
  • [ ] Documentation
  • [ ] Security hardening
  • [x] Tests
  • [ ] Chore/infra

Scope (select all touched areas)

  • [x] Server / API endpoints
  • [ ] Extensions (DID, x402, etc.)
  • [ ] Storage backends
  • [ ] Scheduler backends
  • [ ] Observability / monitoring
  • [x] Authentication / authorization
  • [ ] CLI / utilities
  • [x] Tests
  • [ ] Documentation
  • [ ] CI/CD / infra

Linked Issue/PR

  • Closes #295
  • Related #298

User-Visible / Behavior Changes

  • Users now see a clear toast message when OAuth login fails.
  • Login failures redirect with ?error=<CODE> for UI handling.
  • Consistent error messaging for provider downtime or failures.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/credentials handling changed? (No)
  • New/changed network calls? (No)
  • Database schema/migration changes? (No)
  • Authentication/authorization changes? (No)
  • If any Yes, explain risk + mitigation: None

Verification

Environment

  • OS: Not specified
  • Python version: N/A
  • Storage backend: Not affected
  • Scheduler backend: Not affected

Steps to Test

  1. Simulate OAuth provider failure.
  2. Attempt login via frontend.
  3. Verify redirect and toast message.
  4. Run unit and e2e tests.

Expected Behavior

  • API returns structured 502 error with code + message.
  • UI displays a user-friendly toast message.

Actual Behavior

  • Matches expected behavior; tests passing (20/20).

Evidence (attach at least one)

  • [x] Failing test before + passing after
  • [x] Test output / logs
  • [ ] Screenshot / recording
  • [ ] Performance metrics (if relevant)

Human Verification (required)

What you personally verified (not just CI):

  • Verified scenarios: OAuth provider failure handling, UI error display, structured API response.
  • Edge cases checked: Multiple provider error codes, HTML vs API request handling.
  • What you did NOT verify: Real external provider outage in production.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Database migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert PR #298.
  • Files/config to restore: auth.ts, hooks.server.ts, +server.ts, +layout.svelte, SignInButton
  • Known bad symptoms reviewers should watch for: Missing error toast, broken login UI, incorrect error responses.

Risks and Mitigations

  • Risk: Incorrect error handling could mislead users.
    • Mitigation: Structured error codes + unit and e2e test coverage.

Checklist

  • [x] Tests pass (uv run pytest)
  • [x] Pre-commit hooks pass (uv run pre-commit run --all-files)
  • [ ] Documentation updated (if needed)
  • [x] Security impact assessed
  • [x] Human verification completed
  • [x] Backward compatibility considered

Suvam-paul145 avatar Mar 27 '26 18:03 Suvam-paul145