Skip to content

fix: Enforce seat limit self hosted#6663

Open
matthewelwell wants to merge 12 commits intomainfrom
fix/enforce-seat-limit-self-hosted
Open

fix: Enforce seat limit self hosted#6663
matthewelwell wants to merge 12 commits intomainfrom
fix/enforce-seat-limit-self-hosted

Conversation

@matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Feb 5, 2026

Changes

Enforces seat limits for self-hosted deployments.

Required changes:

  • API should prevent users joining organisations when organisation is already at or over seat limit
  • FE should show information on the number of seats available / being used in the users settings page
  • FE should gracefully handle an invite failing due to there not being enough seats available

Contributes to flagsmith/flagsmith-private#105 and https://github.com/Flagsmith/infrastructure/issues/267

How did you test this code?

Ran the FE locally to verify the FE changes. Added / updated unit tests to verify API changes.

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Feb 20, 2026 4:36pm
flagsmith-frontend-staging Ready Ready Preview, Comment Feb 20, 2026 4:36pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Feb 20, 2026 4:36pm

Request Review

@matthewelwell matthewelwell force-pushed the fix/enforce-seat-limit-self-hosted branch from 3464066 to 31de36b Compare February 19, 2026 18:10
@github-actions github-actions bot added fix and removed fix labels Feb 19, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 19, 2026
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (f644ab2) to head (e87994c).
⚠️ Report is 48 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6663      +/-   ##
==========================================
+ Coverage   98.20%   98.23%   +0.02%     
==========================================
  Files        1298     1312      +14     
  Lines       47108    48503    +1395     
==========================================
+ Hits        46262    47646    +1384     
- Misses        846      857      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@matthewelwell matthewelwell marked this pull request as ready for review February 19, 2026 22:26
@matthewelwell matthewelwell requested review from a team as code owners February 19, 2026 22:26
@matthewelwell matthewelwell requested review from Zaimwa9 and removed request for a team February 19, 2026 22:26
@matthewelwell matthewelwell changed the title fix: enforce seat limit self hosted fix: Enforce seat limit self hosted Feb 19, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 19, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-6663 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-6663 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-6663 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-6663 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6663 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-6663 Finished ✅ Results

Copy link
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

I'd like to confirm that the difference i'm seeing on the error message display is not due to our local setups somehow

switch (detail) {
case 'Not found.':
return 'We could not validate your invite, please check the invite URL and email address you have entered is correct.'
case 'Please upgrade your plan to add additional seats/users':
Copy link
Contributor

@Zaimwa9 Zaimwa9 Feb 20, 2026

Choose a reason for hiding this comment

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

Also I'm realising this will not work with invitation from link.

I am not sure whether it's on purpose as there is a disabled flag verify_seats_limit_for_invite_links used in account-store.controller.acceptInvite.
If we try to join an organisation via link while max seats have been reached the error from the link request gets overridden by the one from users/join/id that will return the No Invite matches the given query:

  acceptInvite: (id) => {
    store.saving()
    API.setInvite('')
    API.setInviteType('')
    return data
      .post(`${Project.api}users/join/link/${id}/`)
      .catch((error) => {
        console.log('error-ajax', error)
        if (
          Utils.getFlagsmithHasFeature('verify_seats_limit_for_invite_links') &&
          error.status === 400
        ) {
          API.ajaxHandler(store, error)
          return // Here it should throw too otherwise below res.id is undefined and crash the app
        }
        return data.post(`${Project.api}users/join/${id}/`)
      })

Then I don't know if this is the way self-hosted are supposed to invite their members

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per discussion, and manual testing, I think this is now resolved in e87994c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments