Skip to content

Fix segment limit counting hidden segments #8369

Open

Description

@talissoncosta

How are you running Flagsmith

  • SaaS at flagsmith.com

Describe the bug

The project segment limit counts feature-specific and system segments, which are hidden from the segments list. A project can therefore hit max_segments_allowed (and show a full Project Usage bar) with far fewer segments visible than the limit.

  • The segments list (SegmentViewSet.get_queryset) excludes system segments always, and feature-specific ones by default (include_feature_specific=false).
  • The usage count and enforcement (Project.live_segment_count(), _validate_project_segment_limit) count every canonical segment, feature-specific and system included.

Feature-specific overrides already have their own limit (max_segment_overrides_allowed), so counting them against max_segments_allowed double-counts them.

Steps To Reproduce

  1. In a project, add enough feature-specific overrides (and/or experiments) that the total canonical segment count approaches max_segments_allowed.
  2. Project Settings → Usage: the Segments bar reads near or at the limit (e.g. 499/500).
  3. Open the Segments list: far fewer segments are shown, since feature-specific are hidden by default.
  4. Try to create a new segment: blocked with "The project has reached the maximum allowed segments limit", despite the visible count being well under the limit.

Expected behavior

The segment limit and the Project Usage count reflect the segments shown in the list (exclude feature-specific and system segments), so the usage matches what a user can see and manage. Feature-specific overrides remain bounded by max_segment_overrides_allowed.

Screenshots

N/A

Activity

  1. changed the title [-]Segment limit counts feature-specific and system segments hidden from the list[/-] [+]Fix segment limit count[/+] on Aug 25, 2026
  2. changed the title [-]Fix segment limit count[/-] [+]Fix segment limit counting hidden segments[/+] on Aug 25, 2026
  3. Ishita-Singh-12 commented on Oct 12, 2026

    @Ishita-Singh-12

    Hi, I would like to work on this. I will make Project.live_segment_count() skip feature-specific and system segments, so the usage count, the create-segment limit and the too-large check all match the segments list, with tests.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions