Skip to content

fix(billing): stop throwing when plans page has no resolved org - #2904

Merged
riderx merged 1 commit into
mainfrom
posthog-self-driving/fixbilling-stop-throwing-when-plans-c9b44e
Aug 7, 2026
Merged

fix(billing): stop throwing when plans page has no resolved org#2904
riderx merged 1 commit into
mainfrom
posthog-self-driving/fixbilling-stop-throwing-when-plans-c9b44e

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 7 users over 3 weeks hit the billing upgrade page (console.capgo.app/settings/organization/plans) and got a broken render with no dialog and no redirect — an unhandled exception, not a caught error.
  • Root cause: loadData() in Plans.vue threw new Error('Cannot get current org id') whenever currentOrganization was still undefined. Two paths reach it with no org set, and setCurrentOrganization silently assigned undefined when handed an id not in the user's org list — exactly what an ?oid= pointing at an org you aren't a member of produces.

Changes:

  • Stop using an exception as control flow. When no org can be resolved, loadData() now bails out gracefully — surfaces the existing cannot-view-plans dialog and routes to /apps, the same recovery the no-permission path already uses (guarded so the watchers don't stack dialogs).
  • No more escaping rejections. The un-awaited loadData(true) call in the route watchEffect now has a catch, so a load failure can never surface as an unhandled rejection.
  • Make the feeder loud. setCurrentOrganization no longer silently clears currentOrganization to undefined on an unknown id — it console.errors and keeps the current org untouched.

Note

#2900 also edits Plans.vue (dark-mode loader / checkout popup). Different intent, no logical overlap — expect only a textual conflict.

Test plan

  • Visit /settings/organization/plans?oid=<an-org-you-are-not-a-member-of>: previously threw an uncaught error and rendered a broken page; now the current org is preserved (the id is rejected loudly in the console) and the page renders normally.
  • With a user that genuinely has no resolvable org, the page shows the cannot-view-plans dialog and redirects to /apps instead of crashing.

Screenshots

Checklist

  • My code follows the code style of this project and passes
    bun run lint:backend && bun run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation
    accordingly.
  • My change has adequate E2E test coverage.
  • I have tested my code manually, and I have provided steps how to reproduce
    my tests

Created with PostHog Desktop from this inbox report.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Review in cubic

The plans page threw `new Error('Cannot get current org id')` from
loadData() when no organization could be resolved, escaping as an
unhandled rejection and leaving users on a broken billing page with no
recovery path.

- loadData() now bails out gracefully instead of throwing: it surfaces
  the existing cannot-view-plans dialog and routes to /apps (the same
  path the no-permission case already uses).
- The un-awaited loadData(true) call in the route watchEffect now has a
  catch so a load failure can never escape as an unhandled rejection.
- setCurrentOrganization() no longer silently assigns undefined when the
  id isn't in the user's org list (what an ?oid= for a non-member org
  produces); it logs loudly and keeps the current org untouched.

Generated-By: PostHog Code
Task-Id: 2aeed371-1257-4461-91ca-3fe9db990e9a
@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing posthog-self-driving/fixbilling-stop-throwing-when-plans-c9b44e (aef04ea) with main (0fdf275)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (0c456b2) during the generation of this report, so 0fdf275 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sonarqubecloud

sonarqubecloud Bot commented Aug 7, 2026

Copy link
Copy Markdown

@riderx
riderx marked this pull request as ready for review August 7, 2026 16:16
@riderx
riderx merged commit 81cbebf into main Aug 7, 2026
78 of 89 checks passed
@riderx
riderx deleted the posthog-self-driving/fixbilling-stop-throwing-when-plans-c9b44e branch August 7, 2026 16:17
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.

1 participant