Skip to content

Organization Deletion Modal Shows Incorrect Link Count #291

@piffio

Description

@piffio

Summary

When attempting to delete an organization, the confirmation modal displays an incorrect number of links that need to be handled (deleted or migrated). The modal shows the monthly link creation count at the billing account level instead of the actual number of links in the specific organization being deleted.

Steps to Reproduce

  1. Set up a Business account with multiple organizations
  2. Import/create links in the main organization (e.g., 11 links)
  3. Create additional organizations with no links
  4. Attempt to delete one of the empty organizations
  5. Observe that the modal warns about links existing in the organization (e.g., shows 1 link instead of 0)
  6. If migration is selected and the target org is also empty, no links are actually moved (because the source org was empty)

Expected Behavior

The modal should show the actual number of links in the organization being deleted (0 for an empty org), not the monthly link creation count across the entire billing account.

Actual Behavior

The modal shows links_created_this_month from the /api/usage endpoint, which counts links at the billing account level (all links created this month across all organizations), not the per-organization link count.

Root Cause

In frontend/src/routes/dashboard/org/+page.svelte (lines 366-368):

// Get link count from usage API
const usage = await orgsApi.getUsage();
linkCount = usage.usage?.links_created_this_month || 0;

The /api/usage endpoint returns links_created_this_month at the billing account level (see src/api/analytics/usage.rs lines 57-59), which is the count of all links created this month across all organizations in the billing account.

Impact

  • Users may incorrectly believe an empty organization contains links
  • This could lead to unnecessary migration operations or incorrect deletion decisions
  • Not currently affecting production users as Business plan is not yet public

Suggested Fix

Add the link count to the /api/orgs/{id} API response, then update the frontend to use this per-organization link count instead of the billing account-level monthly count from /api/usage.

Alternative: Call /api/links filtered by org_id to get the actual count for the specific organization being deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions