Skip to content

Settings page crashes for unauthenticated users#4267

Open
ncarazon wants to merge 1 commit intomainfrom
fix/settings-page-unauthenticated-crash
Open

Settings page crashes for unauthenticated users#4267
ncarazon wants to merge 1 commit intomainfrom
fix/settings-page-unauthenticated-crash

Conversation

@ncarazon
Copy link
Contributor

@ncarazon ncarazon commented Feb 6, 2026

Closes #4236

This PR fixes the account settings page crash for unauthenticated users by adding a redirect to the login page instead of throwing an invariant error.

Changes:

  • Added null check for currentUser in account settings page
  • Redirect unauthenticated users to login page instead of crashing
  • Fixes high-volume Sentry issue (1,230 events since September)

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling on account settings pages (general, account, and notifications). The application now gracefully redirects users to the home page when attempting to access restricted pages without proper authentication, providing a smoother user experience instead of encountering runtime errors.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

Three settings page components replace invariant-based runtime assertions with Next.js redirect guards. When currentUser is unavailable, pages now redirect to "/" instead of throwing errors, providing graceful handling for unauthenticated access.

Changes

Cohort / File(s) Summary
Settings Pages Authentication Guards
front_end/src/app/(main)/accounts/settings/(general)/page.tsx, front_end/src/app/(main)/accounts/settings/account/page.tsx, front_end/src/app/(main)/accounts/settings/notifications/page.tsx
Replace ts-invariant assertion with Next.js redirect() helper. When currentUser is falsy, pages now return redirect("/") instead of throwing, enabling graceful handling of unauthenticated access.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, a skip, where users once crashed,
Now guards redirect with grace so dashed,
No invariants thrown in angry protest—
Just gentle redirects put users to rest! 🌙✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing a crash on settings pages for unauthenticated users, which aligns with the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #4236 by replacing invariant checks with redirect handlers across all affected settings pages (general, account, and notifications), preventing crashes for unauthenticated users.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the crash issue: replacing invariant assertions with redirects in the three affected settings page files, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/settings-page-unauthenticated-crash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings page crashes for unauthenticated users

2 participants