Repository navigation
chore(test-app): start a second environment when a second key is set - #550
abelonogov-ld wants to merge 7 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
LAUNCHDARKLY_SECONDARY_MOBILE_KEY in Secrets.xcconfig, or -LDSecondaryMobileKey at launch, adds a secondary mobile key to the client's LDConfig. An Environment picker then chooses which environment's client the buttons, the connection status, Post 20 MB and the Event storage section use. Restart, Flush, Flush+Wait, Offline and Identify still reach both, as the SDK applies them to every environment. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…nvironments Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # LaunchDarkly/LaunchDarkly/Networking/DarklyService.swift # LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift # LaunchDarkly/LaunchDarklyTests/Networking/DarklyServiceSpec.swift
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cf9e5b5. Configure here.
| self.config = config | ||
| self.context = context | ||
| self.serviceFactory = serviceFactory | ||
| self.payloadFilter = config.validatedPayloadFilter() |
There was a problem hiding this comment.
Flag cache ignores payload filter
Medium Severity
payloadFilter is applied only to stream and poll URLs. Cached flags and their etags stay keyed by mobile key and context, so a new or changed filter still loads the previous payload. Evaluations can then return flags the filter should have excluded, and a polling 304 can keep that stale set, especially while offline.
Reviewed by Cursor Bugbot for commit cf9e5b5. Configure here.
There was a problem hiding this comment.
Risk: medium.
Automated risk review (dry run): Medium
This PR would not be automatically approved. Human approval required.
Why: The diff adds a public SDK payloadFilter option (LDConfig, DarklyService, ObjcLDConfig) and TestApp secondary-environment wiring, and Cursor Bugbot has an unresolved medium-severity finding that flag cache and etags ignore the filter. Human review is needed and no reviewers were assigned.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver




Stacked on #545.
What
When
Config/Secrets.xcconfigsetsLAUNCHDARKLY_SECONDARY_MOBILE_KEY(or the app is launched with-LDSecondaryMobileKey mob-...), the client is started with that key as a secondary environment throughLDConfig.setSecondaryMobileKeys. An Environment picker at the top of Client chooses which environment's client the buttons use. Without the key nothing changes.The selected environment is used by:
These reach both environments whichever is selected, because the SDK applies
close,flush,flushAndWait,setOnlineandidentifyto every environment it started: Restart and the persistence picker, Flush, Flush+Wait, Offline, and Identify. A footer under Client says so.The choice is saved in
UserDefaults, so the launch that answers a kill scenario shows the same environment.InstanceLauncherforwards-LDSecondaryMobileKeyto the instances it starts.Testing
<bundle hash>.<key hash>), each holding its startup log.Note
The SDK keeps
ConnectionInformationunder oneUserDefaultskey for every environment (ConnectionInformationStore). Each environment's status therefore starts out showing whichever environment saved last, until its own connection updates it. This PR doesn't change that SDK behavior.Note
Overview
Adds
payloadFiltertoLDConfig(Swift andObjcLDConfig), withvalidatedPayloadFilter()enforcing LaunchDarkly’s key rules and logging when a bad value is ignored.DarklyServicesends the validated key as afilterquery parameter on streaming and polling flag URLs, combined withwithReasonswhen needed. Contract tests advertisefiltering/filtering-strictand map harnessfilterfields from streaming or polling config.TestApp can load a
LAUNCHDARKLY_SECONDARY_MOBILE_KEY(or-LDSecondaryMobileKey) and start a second environment viasetSecondaryMobileKeys. An Environment picker selects whichLDClientdrives evals, tracking, stress flows, connection status, and per-environment event storage; Restart/Flush/Offline/Identify still affect every started environment. The choice persists inUserDefaults, andInstanceLauncherforwards the secondary key to spawned instances.Reviewed by Cursor Bugbot for commit 993471e. Bugbot is set up for automated code reviews on this repo. Configure here.