Skip to content

feat(usage): return API limit restriction state - #8492

Open
talissoncosta wants to merge 5 commits into
mainfrom
feat/usage-restriction-state-8256
Open

feat(usage): return API limit restriction state#8492
talissoncosta wants to merge 5 commits into
mainfrom
feat/usage-restriction-state-8256

Conversation

@talissoncosta

@talissoncosta talissoncosta commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #8256

The usage page cannot say what a restricted organisation has lost, or whether a free organisation is at risk of being cut off at all. Two read only fields on the organisation response:

Field Meaning
stop_serving_flags flag serving is paused, not only admin access
api_limit_restriction_enabled free plan, and at least one api_limiting_* flag on for this organisation

api_limit_restriction_enabled shares its definition with restrict_use_due_to_api_limit_grace_period_over through a new organisations/services module, so the page and the task cannot drift apart. It compares the plan id to free rather than using the plan family, to match that task, which means an organisation with no plan set reports false.

The grace period half of #8256 needs OrganisationBreachedGracePeriod untangled first, and follows separately.

How did you test this code?

Unit tests cover both fields across plan family, plan id, missing cache, missing subscription and each flag combination, that they stay read only, and a task case for an organisation reached with both flags off, which the previous inline version never exercised. Also checked by hand against a local API, walking a throwaway organisation through each state.

The usage dashboard cannot say what a restricted organisation has lost,
whether a free organisation is at risk at all, or whether an overage can
actually be charged. None of it is on any response.

Adds stop_serving_flags, api_limit_restriction_enabled and
overage_charges_enabled to the organisation response, each sharing its
definition with the task that acts on it via a new organisations/services
module, so the page cannot drift from what those tasks do.

overage_charges_enabled corrects a live wrong message: overages are only
billed on terms of roughly a month, so an annual Start-Up or Scale-Up
organisation is currently told charges may apply when they cannot.

Contributes to #8256

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated
docs Ignored Ignored Preview Sep 10, 2026 1:00pm UTC
flagsmith-frontend-preview Ignored Ignored Preview Sep 10, 2026 1:00pm UTC
flagsmith-frontend-staging Ignored Ignored Preview Sep 10, 2026 1:00pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 79113428-2aea-4bb3-91da-a808019fea4c

📥 Commits

Reviewing files that changed from the base of the PR and between 5c122ee and 1b0c978.

📒 Files selected for processing (7)
  • api/organisations/serializers.py
  • api/organisations/services.py
  • api/tests/unit/organisations/test_unit_organisations_serializers.py
  • api/tests/unit/organisations/test_unit_organisations_services.py
  • frontend/common/types/responses.ts
  • mcp/src/flagsmith_mcp/openapi.json
  • openapi.yaml
💤 Files with no reviewable changes (3)
  • openapi.yaml
  • frontend/common/types/responses.ts
  • mcp/src/flagsmith_mcp/openapi.json

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared service for organisation API-limit restrictions. The grace-period task uses this service to update restriction state and send notifications. The organisation serializer exposes the computed restriction status. Frontend types and OpenAPI schemas include the new organisation fields. Unit tests cover service decisions, task behaviour, serializer output, and ignored restriction-field input.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 1b0c9

The new organisation status fields and restriction logic are covered across service, task, and API serialization paths, with no concrete merge-blocking risk identified.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

@github-actions github-actions Bot added front-end Issue related to the React Front End Dashboard api Issue related to the REST API labels Sep 9, 2026
@talissoncosta talissoncosta changed the title Return API limit restriction state from the API feat(usage): return API limit restriction state Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (e5a1ec0) to head (1b0c978).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #8492    +/-   ##
========================================
  Coverage   98.82%   98.82%            
========================================
  Files        1622     1624     +2     
  Lines       66708    66981   +273     
========================================
+ Hits        65923    66197   +274     
+ Misses        785      784     -1     

☔ View full report in Codecov by Harness.
📢 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.

Whether an overage can actually be charged is not what #8256 asks for,
and the usage dashboard epic puts overage cost out of scope. It also
carries its own argument, that annual plans are never billed for
overages, which deserves its own review rather than riding along here.

Leaves this change to the one question the issue does ask: can this
organisation be cut off.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Sep 10, 2026
@talissoncosta
talissoncosta marked this pull request as ready for review September 11, 2026 20:56
@talissoncosta
talissoncosta requested review from a team as code owners September 11, 2026 20:56
@talissoncosta
talissoncosta requested review from kyle-ssg and matthewelwell and removed request for a team September 11, 2026 20:56
@github-actions github-actions Bot removed the feature New feature or request label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@github-actions github-actions Bot added the feature New feature or request label Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #20412 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  37.8 seconds
commit  1b0c978
info  🔄 Run: #20412 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #20412 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  4 passed

Details

stats  4 tests across 4 suites
duration  35 seconds
commit  1b0c978
info  🔄 Run: #20412 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #20412 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.7 seconds
commit  1b0c978
info  🔄 Run: #20412 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #20412 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.2 seconds
commit  1b0c978
info  🔄 Run: #20412 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

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 feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant