Skip to content

feat(Segment membership inspection): Add segment members read endpoint#7861

Open
khvn26 wants to merge 3 commits into
mainfrom
feat/segment-membership-read-endpoint
Open

feat(Segment membership inspection): Add segment members read endpoint#7861
khvn26 wants to merge 3 commits into
mainfrom
feat/segment-membership-read-endpoint

Conversation

@khvn26

@khvn26 khvn26 commented Jun 24, 2026

Copy link
Copy Markdown
Member

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

Closes #7408.

Adds a read endpoint that lists the identities currently matching a segment, cursor-paginated.

GET /api/v1/projects/{project_id}/segments/{id}/members?environment={env_id}&cursor={identifier}&limit={N}

How did you test this code?

Added integration and unit tests.

Will test extensively in staging.

Add GET /projects/{id}/segments/{id}/members, listing the identities
matching a segment in an environment, cursor-paginated against the
ClickHouse IDENTITIES snapshot the membership backfill maintains.

- Reuses the count-refresh SQL predicate against FROM IDENTITIES FINAL,
  env-scoped, ordered by identifier ASC; limit capped at 200 (400 above).
- RBAC: MANAGE_SEGMENTS on the project plus VIEW_IDENTITIES on the
  environment; gated on the segment_membership_inspection flag (404 when off).
- Emits flagsmith_segment_membership_read_duration_seconds and tags every
  query with a :read: log_comment for ClickHouse spend attribution.

beep boop
@khvn26 khvn26 requested review from a team as code owners June 24, 2026 11:08
@khvn26 khvn26 requested review from matthewelwell and removed request for a team June 24, 2026 11:08
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 24, 2026 4:59pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Jun 24, 2026 4:59pm
flagsmith-frontend-staging Ignored Ignored Preview Jun 24, 2026 4:59pm

Request Review

@khvn26 khvn26 changed the title feat(segment-membership): Add segment members read endpoint feat(Segment membership inspection): Add segment members read endpoint Jun 24, 2026
@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.60%. Comparing base (929e1df) to head (67c44d3).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7861      +/-   ##
==========================================
+ Coverage   98.59%   98.60%   +0.01%     
==========================================
  Files        1472     1476       +4     
  Lines       57362    57853     +491     
==========================================
+ Hits        56556    57047     +491     
  Misses        806      806              

☔ 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.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  35.6 seconds
commit  bd697d7
info  🔄 Run: #17773 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  46 seconds
commit  bd697d7
info  🔄 Run: #17773 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 2 suites
duration  38.9 seconds
commit  bd697d7
info  🔄 Run: #17773 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  11.6 seconds
commit  bd697d7
info  🔄 Run: #17773 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.7 seconds
commit  f38f7ce
info  🔄 Run: #17788 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.4 seconds
commit  f38f7ce
info  🔄 Run: #17788 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.2 seconds
commit  f38f7ce
info  🔄 Run: #17788 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  58.9 seconds
commit  f38f7ce
info  🔄 Run: #17788 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  42 seconds
commit  67c44d3
info  🔄 Run: #17790 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.5 seconds
commit  67c44d3
info  🔄 Run: #17790 (attempt 1)

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

passed  5 passed

Details

stats  5 tests across 4 suites
duration  39.4 seconds
commit  67c44d3
info  🔄 Run: #17790 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.9 seconds
commit  67c44d3
info  🔄 Run: #17790 (attempt 1)

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

… no more rows

At an exact page boundary (matches == limit) the endpoint returned a
next_cursor, so paging through it yielded an empty trailing page. Fetch one
extra row (limit + 1) to detect a real next page, and only set next_cursor
when that probe row exists.

beep boop
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@github-actions github-actions Bot added docs Documentation updates and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@github-actions github-actions Bot added the feature New feature or request label Jun 24, 2026

@emyller emyller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great. One product-related question.

Comment thread api/segments/serializers.py
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement new endpoint to return current members of a given segment

3 participants