Skip to content

Comments

fix(billing): treat missing seats addon as supported#2881

Merged
HarshMN2345 merged 4 commits intomainfrom
fix-missing-seats
Feb 24, 2026
Merged

fix(billing): treat missing seats addon as supported#2881
HarshMN2345 merged 4 commits intomainfrom
fix-missing-seats

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Feb 24, 2026

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.)

Summary by CodeRabbit

  • Bug Fixes
    • Safer handling of missing or incomplete billing-plan data to prevent runtime errors.
    • Invite, member-management, and upgrade prompts updated to default to supported seats when billing details are absent, avoiding misleading upgrade messages and consistently showing correct membership limits.

@appwrite
Copy link

appwrite bot commented Feb 24, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Function scopes give you fine-grained control over API permissions

@HarshMN2345 HarshMN2345 requested a review from Meldiron February 24, 2026 09:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 440dc32 and 8ef237b.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte

Walkthrough

The PR makes defensive updates in three Svelte components under console routes. Deep reads of billingPlanDetails.addons.seats.supported were replaced with optional chaining and a default (?. and ?? true). One template conditional was inverted to reflect the new boolean semantics, and a tooltip condition was adjusted to use the safer expression. These edits change control flow when nested billing data is missing and avoid potential runtime errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change across all three files: adding optional chaining and treating missing seats addon data as supported by defaulting to true.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-missing-seats

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(console)/organization-[organization]/header.svelte (1)

154-158: ⚠️ Potential issue | 🟠 Major

Guard plan name access when seats addon is missing.

With ?? true, missing billingPlanDetails routes into the else-branch, which still reads organization?.billingPlanDetails.name and can throw when billingPlanDetails is absent (self‑hosted). Add optional chaining and a fallback for the plan name.

🛠️ Suggested fix
-                                {!(organization?.billingPlanDetails?.addons?.seats?.supported ?? true)
-                                    ? 'Upgrade to add more members'
-                                    : `You've reached the members limit for the ${
-                                          organization?.billingPlanDetails.name
-                                      } plan`}
+                                {!(organization?.billingPlanDetails?.addons?.seats?.supported ?? true)
+                                    ? 'Upgrade to add more members'
+                                    : `You've reached the members limit for the ${
+                                          organization?.billingPlanDetails?.name ?? 'current'
+                                      } plan`}
Based on learnings: billingPlanDetails is cloud-only in the Appwrite Console. When accessing billing-related properties in any Svelte file, guard with isCloud or use defensive access (e.g., optional chaining or explicit null checks) to support both cloud and self-hosted deployments. Prefer guards around billingPlanDetails access and avoid assuming presence; implement pattern like if (isCloud) { ... } or use billingPlanDetails?.property with appropriate fallbacks.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/`(console)/organization-[organization]/header.svelte around lines
154 - 158, The current conditional can still read
organization?.billingPlanDetails.name when billingPlanDetails is missing; update
the expression to defensively access the plan name (e.g., use
organization?.billingPlanDetails?.name ?? 'your plan' or similar fallback) or
wrap the whole billing branch with an isCloud guard so we never dereference
billingPlanDetails when absent; specifically modify the template expression that
references organization?.billingPlanDetails?.addons?.seats?.supported and
organization?.billingPlanDetails.name to use optional chaining and a sensible
fallback for the plan name (or guard with isCloud) to support self‑hosted
deployments.
🧹 Nitpick comments (1)
src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte (1)

14-15: Logic looks good; consider dropping the inline comment.

The boolean flip and default look consistent with the intended behavior. The inline comment isn’t a TODO or complex logic explanation, so it can be removed to match comment-minimization guidelines.

✂️ Comment cleanup
-    $: organizationMembersSupported =
-        $organization?.billingPlanDetails?.addons?.seats?.supported ?? true; /* false on free */
+    $: organizationMembersSupported =
+        $organization?.billingPlanDetails?.addons?.seats?.supported ?? true;
As per coding guidelines: Use minimal comments; only comment TODOs or complex logic.

Also applies to: 22-22

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/routes/`(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte
around lines 14 - 15, Remove the inline comment after the reactive declaration
for organizationMembersSupported; update the expression `$:
organizationMembersSupported =
$organization?.billingPlanDetails?.addons?.seats?.supported ?? true;` by
deleting the trailing `/* false on free */` comment, and also remove the similar
extraneous inline comment at the other occurrence noted (the second occurrence
of the same reactive assignment) so only the code remains with no inline
explanatory comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/routes/`(console)/organization-[organization]/header.svelte:
- Around line 154-158: The current conditional can still read
organization?.billingPlanDetails.name when billingPlanDetails is missing; update
the expression to defensively access the plan name (e.g., use
organization?.billingPlanDetails?.name ?? 'your plan' or similar fallback) or
wrap the whole billing branch with an isCloud guard so we never dereference
billingPlanDetails when absent; specifically modify the template expression that
references organization?.billingPlanDetails?.addons?.seats?.supported and
organization?.billingPlanDetails.name to use optional chaining and a sensible
fallback for the plan name (or guard with isCloud) to support self‑hosted
deployments.

---

Nitpick comments:
In
`@src/routes/`(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte:
- Around line 14-15: Remove the inline comment after the reactive declaration
for organizationMembersSupported; update the expression `$:
organizationMembersSupported =
$organization?.billingPlanDetails?.addons?.seats?.supported ?? true;` by
deleting the trailing `/* false on free */` comment, and also remove the similar
extraneous inline comment at the other occurrence noted (the second occurrence
of the same reactive assignment) so only the code remains with no inline
explanatory comment.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35c23ea and 33c435b.

📒 Files selected for processing (3)
  • src/routes/(console)/apply-credit/+page.svelte
  • src/routes/(console)/organization-[organization]/header.svelte
  • src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

Added defensive null-checking with optional chaining (?.) and nullish coalescing (?? true) to prevent runtime errors when billingPlanDetails.addons.seats is missing or incomplete. The changes treat missing seats addon data as "supported" (defaults to true), which allows paid plans without explicit seats configuration to function correctly. Also inverted the logic in totalMembers.svelte to match the new default behavior and updated the comment accordingly.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward defensive programming improvements that add proper null-safety checks. All instances of accessing billingPlanDetails.addons.seats have been updated consistently with optional chaining. The logic is sound and prevents crashes without changing core functionality.
  • No files require special attention

Important Files Changed

Filename Overview
src/routes/(console)/apply-credit/+page.svelte Added optional chaining to prevent crashes when seats addon is missing
src/routes/(console)/organization-[organization]/header.svelte Added optional chaining to safely access seats addon properties in tooltip logic
src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte Fixed logic inversion and added optional chaining; defaults missing seats addon to supported (true)

Last reviewed commit: 8ef237b

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

…ce]]/totalMembers.svelte

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(console)/organization-[organization]/header.svelte (1)

154-162: ⚠️ Potential issue | 🟡 Minor

Inconsistent optional chaining on billingPlanDetails.name in the else branch (line 160)

The new ?? true default means the false / else branch ("You've reached the members limit…") is now also taken when billingPlanDetails, addons, seats, or supported is missing. In that path, line 160 dereferences organization?.billingPlanDetails.name with no ?. on billingPlanDetails. If billingPlanDetails were ever absent, this would throw at runtime.

Per project learnings, billingPlanDetails is guaranteed to be present for a loaded organization — so this is not an active bug — but it creates a contradiction with the defensive pattern introduced just a few lines above. A ?. on billingPlanDetails on line 160 keeps the whole block consistent.

🛡️ Proposed fix for consistency
-                                    : `You've reached the members limit for the ${
-                                          organization?.billingPlanDetails.name
-                                      } plan`}
+                                    : `You've reached the members limit for the ${
+                                          organization?.billingPlanDetails?.name
+                                      } plan`}

Based on learnings: "Guards for billingPlanDetails existence are unnecessary when the organization is loaded. If it's missing, it indicates a backend issue." However, the inconsistency introduced here — where the ?? true fallback now routes missing-data cases into the else branch that still uses non-optional billingPlanDetails.name — warrants aligning the access style.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/`(console)/organization-[organization]/header.svelte around lines
154 - 162, The else branch dereferences billingPlanDetails without optional
chaining (organization?.billingPlanDetails.name) while the condition uses a
nullish default, so if billingPlanDetails is missing the template could throw;
update the else branch to use optional chaining
(organization?.billingPlanDetails?.name) so the access matches the guarded
pattern around organization?.billingPlanDetails and avoids runtime errors in the
`You've reached the members limit…` message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/routes/`(console)/organization-[organization]/header.svelte:
- Around line 154-162: The else branch dereferences billingPlanDetails without
optional chaining (organization?.billingPlanDetails.name) while the condition
uses a nullish default, so if billingPlanDetails is missing the template could
throw; update the else branch to use optional chaining
(organization?.billingPlanDetails?.name) so the access matches the guarded
pattern around organization?.billingPlanDetails and avoids runtime errors in the
`You've reached the members limit…` message.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9fb2fb and 440dc32.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/header.svelte

@HarshMN2345 HarshMN2345 merged commit a41047e into main Feb 24, 2026
5 checks passed
@HarshMN2345 HarshMN2345 deleted the fix-missing-seats branch February 24, 2026 11:46
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