Skip to content

fix: guard against null billing plan cache entries#2958

Merged
TorstenDittmann merged 1 commit intomainfrom
fix-0-self-hosted-billing-plan-null-crash
Apr 6, 2026
Merged

fix: guard against null billing plan cache entries#2958
TorstenDittmann merged 1 commit intomainfrom
fix-0-self-hosted-billing-plan-null-crash

Conversation

@TorstenDittmann
Copy link
Copy Markdown
Contributor

Summary

  • prevent getBasePlanFromGroup() from reading .group from falsy plan entries in the cached plans map
  • avoid caching a null organizationPlan in the project layout on self-hosted installs
  • fix the self-hosted billing plan lookup crash without changing broader billing behavior

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR fixes a crash on self-hosted installs by guarding two places where a null billing plan value could enter the plansInfo store and subsequently cause a runtime error.

  • +layout.ts: The root cause — on self-hosted installs isCloud is false, so organizationPlan is always null. The previous code unconditionally called plansInfo.set(organization.billingPlanId, null) when the plan wasn't in the base-plans cache, inserting a null entry into a Map<string, Models.BillingPlan>. The fix adds an && organizationPlan guard that prevents the null write entirely.
  • billing.ts: getBasePlanFromGroup() now uses a type predicate filter (plan): plan is Models.BillingPlan => !!plan && ... to skip falsy entries before accessing .group, acting as a defence-in-depth guard against any residual null values that may already be in the map.

Both changes are minimal, non-breaking, and correct — the added guards are transparent to cloud users where organizationPlan is always a real object.

Confidence Score: 5/5

Safe to merge — both changes are narrow null guards with no behavioral change for cloud installs.

No P0 or P1 issues found. The fix in +layout.ts correctly addresses the root cause (null being stored in a Map<string, Models.BillingPlan>), and the billing.ts fix adds a complementary defence-in-depth guard. Logic is unchanged for truthy organizationPlan values, so cloud behavior is unaffected.

No files require special attention — both changes are safe and well-scoped.

Important Files Changed

Filename Overview
src/lib/stores/billing.ts Adds a null/falsy type-guard in getBasePlanFromGroup's filter to prevent accessing .group on null plan entries
src/routes/(console)/project-[region]-[project]/+layout.ts Guards plansInfo.set() with an organizationPlan truthiness check, preventing null from being cached into the plans map on self-hosted installs

Reviews (1): Last reviewed commit: "fix: guard against null billing plan cac..." | Re-trigger Greptile

@TorstenDittmann TorstenDittmann merged commit af0b0d3 into main Apr 6, 2026
4 checks passed
@TorstenDittmann TorstenDittmann deleted the fix-0-self-hosted-billing-plan-null-crash branch April 6, 2026 18:35
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.

2 participants