From d4fb158a1666e02a351c7fd163be7be6f31f7b31 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan Date: Tue, 7 Apr 2026 19:10:21 +0530 Subject: [PATCH] fix(console): guard organization access in realtimePricing to prevent runtime crash --- .../components/billing/alerts/realtimePricing.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/components/billing/alerts/realtimePricing.svelte b/src/lib/components/billing/alerts/realtimePricing.svelte index f0ae6ff22..cd74b93ad 100644 --- a/src/lib/components/billing/alerts/realtimePricing.svelte +++ b/src/lib/components/billing/alerts/realtimePricing.svelte @@ -16,9 +16,14 @@ } } - $: href = $currentPlan?.usagePerProject - ? `${base}/organization-${$organization.$id}/billing` - : `${base}/organization-${$organization.$id}/usage`; + // Guard org id: this reactive runs even when the {#if} below is false, so optional + // chaining on $currentPlan alone is not enough — $organization can be undefined. + $: orgId = $organization?.$id; + $: href = orgId + ? $currentPlan?.usagePerProject + ? `${base}/organization-${orgId}/billing` + : `${base}/organization-${orgId}/usage` + : ''; {#if $organization?.$id && !dismissed}