feat: Exclude verified Edge Proxy requests from API usage tracking - #8407
feat: Exclude verified Edge Proxy requests from API usage tracking#8407gagantrivedi wants to merge 3 commits into
Conversation
An Edge Proxy sends X-Proxy-Key on its environment-document fetches and reports the requests it serves through its own usage endpoint, so counting its fetches here would double-count. The private edge_proxy app's is_edge_proxy_request() decides the exemption — it verifies the key and that its grants cover the presented environment, so a spoofed header never dodges metering. Wired only on non-SaaS deployments with the edge_proxy app installed; requires the flagsmith-private release that ships is_edge_proxy_request (bump the lock before merge).
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueNo actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR excludes only verified Edge Proxy requests from API usage tracking while retaining tracking when verification is unavailable; no actionable merge-blocking risk remains after normal checks and review. 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. Comment |
|
Companion PRs for Flagsmith/flagsmith-private#256:
Merge/deploy order: #282 and 8407 (with the flagsmith-private pin bump) before any proxy build with #19 is deployed, else document polls double-count during the overlap. |
Docker builds report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/edge-proxy-app-wiring #8407 +/- ##
===========================================================
Coverage 98.81% 98.81%
===========================================================
Files 1621 1621
Lines 66103 66147 +44
===========================================================
+ Hits 65319 65363 +44
Misses 784 784 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
✅ oss · depot-ubuntu-latest-arm-16 — run #19949 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
🗂️ Previous results✅ oss · depot-ubuntu-latest-16 — run #19949 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-16)Details
|
Core's lock pins a flagsmith-private wheel that does not ship the helper yet, so a hard import broke every request in CI. Feature-detect instead: on an older wheel the proxy's fetches are simply counted as before, and the exclusion activates when the pin catches up.
Changes
Contributes to Flagsmith/flagsmith-private#256
An Edge Proxy reports the requests it serves through its own usage endpoint, so counting its
/environment-document/fetches here would double-count.APIUsageMiddlewarenow skips a request when the privateedge_proxyapp verifies it as the proxy's own —is_edge_proxy_request()checks theX-Proxy-Keyvalue and that the key's grants cover the presented environment. Bare header presence is never trusted, so the header can't be spoofed to dodge metering.Wired only on non-SaaS deployments with the
edge_proxyapp installed; SaaS behaviour is untouched.Stacked on #8305. Before merge: bump the
flagsmith-privatepin to the release that shipsis_edge_proxy_request.How did you test this code?
19 middleware unit tests: verifier wired only when installed + non-SaaS; verified requests untracked, unverified tracked; a proxy header with no verifier available still tracked (spoof regression); existing tracking cases unchanged. The verifier itself is tested against a real database in flagsmith-private.