Skip to content

chore(__future__): Drop the AnonymousUser asserts and the strict log assertions - #8308

Merged
khvn26 merged 2 commits into
mainfrom
chore/update-flag-cleanup
Aug 17, 2026
Merged

chore(__future__): Drop the AnonymousUser asserts and the strict log assertions#8308
khvn26 merged 2 commits into
mainfrom
chore/update-flag-cleanup

Conversation

@khvn26

@khvn26 khvn26 commented Aug 15, 2026

Copy link
Copy Markdown
Member
  • 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

Cleanup only — no behaviour changes.

In this PR, we remove the not isinstance(request.user, AnonymousUser) littered across the codebase in favour of a centralised AuthenticatedRequest type, and migrate most of the logging assertions to log.has to avoid having to call log.events.clear() in the functional tests' fixtures.

Stacked on #8307.

How did you test this code?

Green CI is sufficient.

@khvn26
khvn26 requested review from a team as code owners August 15, 2026 14:35
@khvn26
khvn26 requested review from emyller and removed request for a team August 15, 2026 14:35
@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Aug 16, 2026 3:38pm
flagsmith-frontend-preview Ignored Ignored Preview Aug 16, 2026 3:38pm
flagsmith-frontend-staging Ignored Ignored Preview Aug 16, 2026 3:38pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds AuthenticatedRequest with a narrowed authenticated user type. Future flag and segment-override views use this type and no longer require anonymous-user assertions. Integration tests now match relevant structured-log fields instead of comparing complete event lists. Unneeded log resets were removed, and unauthorised deletion checks verify that no matching update event exists. The events catalogue source line was corrected.

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

Merge Risk: 🔵 Low · up to d54e5

Production behavior is unchanged, but one integration test can pass without verifying the event generated by the tested update request because it may match an earlier setup event. The PR is mergeable with explicit owner follow-up to restore the event boundary or assert the newly generated event.


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 api Issue related to the REST API docs Documentation updates chore and removed docs Documentation updates labels Aug 15, 2026
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (b3b2b31) to head (d54e52f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8308      +/-   ##
==========================================
- Coverage   98.78%   98.78%   -0.01%     
==========================================
  Files        1604     1605       +1     
  Lines       64426    64417       -9     
==========================================
- Hits        63642    63633       -9     
  Misses        784      784              

☔ 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 Aug 15, 2026

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

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

passed  4 passed

Details

stats  4 tests across 4 suites
duration  1 minute, 15 seconds
commit  d54e52f
info  🔄 Run: #19451 (attempt 1)

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

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  57 seconds
commit  d54e52f
info  🔄 Run: #19451 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41 seconds
commit  d54e52f
info  🔄 Run: #19451 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.2 seconds
commit  d54e52f
info  🔄 Run: #19451 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19448 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  55.6 seconds
commit  649a5ce
info  🔄 Run: #19448 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19448 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  37.8 seconds
commit  649a5ce
info  🔄 Run: #19448 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19444 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  36.6 seconds
commit  649a5ce
info  🔄 Run: #19444 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19444 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  40.3 seconds
commit  649a5ce
info  🔄 Run: #19444 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.5 seconds
commit  649a5ce
info  🔄 Run: #19444 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.2 seconds
commit  649a5ce
info  🔄 Run: #19448 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.3 seconds
commit  649a5ce
info  🔄 Run: #19448 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.4 seconds
commit  649a5ce
info  🔄 Run: #19444 (attempt 1)

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

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

@khvn26
khvn26 force-pushed the chore/update-flag-cleanup branch from 9d15706 to edf5f8b Compare August 16, 2026 12:28
@github-actions github-actions Bot added docs Documentation updates chore and removed docs Documentation updates chore labels Aug 16, 2026
@khvn26
khvn26 force-pushed the chore/update-flag-cleanup branch from edf5f8b to 83e1f4c Compare August 16, 2026 13:32
@github-actions github-actions Bot added docs Documentation updates chore and removed docs Documentation updates chore labels Aug 16, 2026
@khvn26
khvn26 force-pushed the chore/update-flag-cleanup branch from 83e1f4c to 5a325c7 Compare August 16, 2026 14:02
@github-actions github-actions Bot removed the docs Documentation updates label Aug 16, 2026
@github-actions github-actions Bot added chore and removed chore labels Aug 16, 2026
@khvn26
khvn26 force-pushed the chore/update-flag-cleanup branch from 5a325c7 to 649a5ce Compare August 16, 2026 14:37
@github-actions github-actions Bot added docs Documentation updates chore and removed docs Documentation updates chore labels Aug 16, 2026
Base automatically changed from feat/update-flag-delete to main August 16, 2026 15:38
@khvn26
khvn26 requested review from a team as code owners August 16, 2026 15:38
@khvn26
khvn26 force-pushed the chore/update-flag-cleanup branch from 649a5ce to d54e52f Compare August 16, 2026 15:38
@github-actions github-actions Bot added docs Documentation updates chore and removed docs Documentation updates chore labels Aug 16, 2026

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/tests/integration/features/future/test_flag_endpoint.py (1)

1238-1238: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Retain a log boundary for this test.

The setup PATCH and the tested PUT both emit flag.updated with the same identity fields and empty segment_overrides__*__segment__ids values. After the reset at Line 1238 was removed, the assertion in Lines 1263-1273 can match the setup event. The test can pass without verifying the PUT event.

Restore log.events.clear() after the setup response, or assert a newly captured event after the PUT.

Suggested fix
     assert setup_response.status_code == 200
+    log.events.clear()

     # When

Also applies to: 1263-1273


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e9f70ce7-8676-43ae-b485-2cd09b6961a5

📥 Commits

Reviewing files that changed from the base of the PR and between b3b2b31 and d54e52f.

📒 Files selected for processing (4)
  • api/core/types.py
  • api/features/future/views.py
  • api/tests/integration/features/future/test_flag_endpoint.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.

@khvn26
khvn26 merged commit a35dcd1 into main Aug 17, 2026
35 checks passed
@khvn26
khvn26 deleted the chore/update-flag-cleanup branch August 17, 2026 11:31
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 chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants