Conversation
PR SummaryHigh Risk Overview New Reviewed by Cursor Bugbot for commit eda1b1f. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Concurrent cache refreshes can cause periodic LaunchDarkly request stampedes.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds a LaunchDarkly-controlled admin bypass to the API gateway’s entitlement resolution.
Changes:
- Parses individually targeted admin LFIDs and caches them for 60 seconds.
- Applies provisional admin organization and tier headers.
- Adds environment configuration, documentation, and tests.
| File | Description |
|---|---|
.dev.vars.example |
Adds LaunchDarkly variables. |
README.md |
Documents admin bypass behavior. |
src/env.ts |
Types LaunchDarkly configuration. |
src/flags.ts |
Fetches, parses, and caches admin targets. |
src/index.ts |
Integrates admin entitlement resolution. |
tests/flags.test.ts |
Tests flag parsing and caching. |
tests/gateway.test.ts |
Tests admin header forwarding. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5d6007d to
0b6ad41
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Admin authorization currently relies on the noncanonical username claim rather than the immutable JWT subject.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Resolved since last review (1)
0b6ad41 to
0fc6699
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The LaunchDarkly request and response handling do not match its polling API, preventing the admin list from loading.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Resolved since last review (1)
gaspergrom
left a comment
There was a problem hiding this comment.
One question on the flag fetch before this merges, left inline.
| try { | ||
| const response = await fetch(env.LD_FLAG_URL, { headers: { authorization: env.LD_SDK_KEY } }); | ||
| if (!response.ok) throw new Error(`LaunchDarkly flag request failed: ${response.status}`); | ||
| cached = { usernames: targetedUsernames(await response.json()), fetchedAt: Date.now() }; |
There was a problem hiding this comment.
How does LD_FLAG_URL map to a real LaunchDarkly endpoint? SDK-key polling normally returns the whole environment's flags and segments, not one flag's on/variations/targets shape. If LD_FLAG_URL points there, flag.on stays undefined and the feature excludes every admin with no error. Does a proxy sit in front of LD and return just this flag, or should this pull the flag by key from the polling response first?
There was a problem hiding this comment.
LD_FLAG_URL is the per-flag polling path /sdk/latest-flags/insights-public-api, which returns that one flag config (older server SDKs fetch by key this way). tests use that path now in e3dfc40, will confirm against the real env once the SDK key is set
0fc6699 to
e3dfc40
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The previously identified LaunchDarkly polling endpoint mismatch remains unresolved and prevents the configured flag from being parsed correctly.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: None
Resolved since last review (1)
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
e3dfc40 to
eda1b1f
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The LaunchDarkly request needs a timeout so stalled lookups cannot block entitlement-cache misses.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
| export async function fetchAdminUsernames(env: Env): Promise<string[]> { | ||
| if (cached && Date.now() - cached.fetchedAt < REFRESH_MS) return cached.usernames; | ||
| try { | ||
| const response = await fetch(env.LD_FLAG_URL, { headers: { authorization: env.LD_SDK_KEY } }); |
gaspergrom
left a comment
There was a problem hiding this comment.
Approving, thanks for the fixes.


LFIDs individually targeted with
trueon a LaunchDarkly boolean flag skip member-tiers and get the adminx-org-idandx-tier.LD_FLAG_URLwithLD_SDK_KEYand reads individual targets only; rules and segments are ignored, and a flag that is off yields no admins.lfx-admin/admin) until the API's tier collapse defines an admin pool.Stacked on #2311.
main