Skip to content

feat(usage): expose whether an organisation is blocked for API usage - #8808

Open
PiUnknown wants to merge 1 commit into
Flagsmith:mainfrom
PiUnknown:feat/8773-api-limit-access-blocked
Open

PiUnknown wants to merge 1 commit into
Flagsmith:mainfrom
PiUnknown:feat/8773-api-limit-access-blocked

Conversation

@PiUnknown

Copy link
Copy Markdown

Closes #8773.

Changes

  • Adds a read-only api_limit_access_blocked boolean to the organisation response, true when an APILimitAccessBlock exists.
  • Prefetches the relation in OrganisationViewSet to avoid an N+1 query.
  • Updates the usage dashboard type and banner so API-limit blocks and support-set blocks show distinct recovery guidance.
  • Updates both OpenAPI schemas and adds serializer/view tests.

How did you test this code?

  • Added backend unit tests for the serialised field with and without an APILimitAccessBlock.
  • Added an API test for GET /api/v1/organisations/{id}/.
  • Added frontend unit tests for the new restricted-status flag and both recovery messages.
  • Ran ruff check, ruff format --check, and Prettier 3.4.2 checks on the changed files.

The full backend/frontend suites were not run locally because Docker/PostgreSQL and frontend node_modules were unavailable.

Add a read-only api_limit_access_blocked field to the organisation response so the usage dashboard can explain whether access returns automatically or requires support.
@PiUnknown
PiUnknown requested review from a team as code owners October 19, 2026 15:52
@PiUnknown
PiUnknown requested review from emyller and removed request for a team October 19, 2026 15:52
@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@PiUnknown is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added front-end Issue related to the React Front End Dashboard api Issue related to the REST API labels Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

The organisation API response now includes a read-only api_limit_access_blocked boolean. The usage interface uses this value to distinguish API-limit blocks from support-imposed blocks and show the corresponding recovery instructions. Backend and frontend tests cover both block states.

Priority: ➖ Normal

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

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to a5d23

Organisations blocked only by the API limit may not see the intended recovery guidance. Include the new block flag in restricted-status detection before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 0f624b96-9dab-48f4-a16c-f5308c75a06c
📥 Commits

Reviewing files that changed from the base of the PR and between e40b88b and a5d2337.

📒 Files selected for processing: 12
  • api/organisations/serializers.py
  • api/organisations/views.py
  • api/tests/unit/organisations/test_unit_organisations_serializers.py
  • api/tests/unit/organisations/test_unit_organisations_views.py
  • frontend/common/types/responses.ts
  • frontend/documentation/components/UsageDashboard.stories.tsx
  • frontend/web/components/pages/usage/__tests__/limitStatus.test.ts
  • frontend/web/components/pages/usage/__tests__/limitStatusMessage.test.ts
  • frontend/web/components/pages/usage/limitStatus.ts
  • frontend/web/components/pages/usage/limitStatusMessage.ts
  • mcp/src/flagsmith_mcp/openapi.json
  • openapi.yaml

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@@ -42,6 +45,7 @@ export const limitStatusOf = (
// The block outlives going over the limit, so this cannot key off over.
if (organisation?.block_access_to_admin || organisation?.stop_serving_flags) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Include the API-limit block in the restricted-status condition.

When api_limit_access_blocked is true and both existing restriction flags are false, this condition skips the restricted status. With no overage, limitStatusOf returns undefined. The new API-limit-only case in frontend/web/components/pages/usage/__tests__/limitStatus.test.ts therefore fails, and the recovery message cannot appear for that state. Include organisation?.api_limit_access_blocked in this condition.

This branch has not been deployed

No deployments
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 front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose whether an organisation is blocked for API usage

1 participant