fix(console): guard organization access in realtimePricing to prevent runtime crash#2961
fix(console): guard organization access in realtimePricing to prevent runtime crash#2961HarshMN2345 merged 1 commit intomainfrom
Conversation
Greptile SummaryThis PR fixes a real runtime crash in
Confidence Score: 5/5Safe to merge — the fix correctly prevents a real runtime crash with no regressions introduced. All remaining findings are P2 style/convention suggestions (extra reactive variable, Svelte 5 migration). There are no P0 or P1 defects in the changed code. No files require special attention beyond the style suggestions noted. Important Files Changed
|
| $: orgId = $organization?.$id; | ||
| $: href = orgId | ||
| ? $currentPlan?.usagePerProject | ||
| ? `${base}/organization-${orgId}/billing` | ||
| : `${base}/organization-${orgId}/usage` | ||
| : ''; |
There was a problem hiding this comment.
Unnecessary intermediate reactive variable
The extra $: orgId = $organization?.$id reactive declaration adds a second reactive dependency chain where one is sufficient. Since orgId is used only inside the href expression, you can inline the guard directly:
| $: orgId = $organization?.$id; | |
| $: href = orgId | |
| ? $currentPlan?.usagePerProject | |
| ? `${base}/organization-${orgId}/billing` | |
| : `${base}/organization-${orgId}/usage` | |
| : ''; | |
| $: href = $organization?.$id | |
| ? $currentPlan?.usagePerProject | |
| ? `${base}/organization-${$organization.$id}/billing` | |
| : `${base}/organization-${$organization.$id}/usage` | |
| : ''; |
This achieves the same crash protection with one fewer reactive declaration, and keeps the intent clear: href is empty when the org is not loaded.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)