You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
deps: update dependency flagsmith/sdk-spec to v0.7.0 - #68
To trigger a single review, invoke the @coderabbitai review command.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 7cf79612-13c6-4b58-86c8-9fe1a1b4e332
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
🔍 Trigger review
Walkthrough
The Rust client adds optional experiment metadata to flags and event tracking with configurable buffering and delivery. New client methods retrieve experiment flags, track custom events and exposure events, and flush buffered events. The SDK spec adds steps for these operations and updates its reusable workflow reference.
Bound event queue growth and ensure retries run during sustained traffic before merging. Experiment exposure recording should also enforce the nonblank identity requirement. These changes reduce memory-exhaustion risk and prevent avoidable exposure loss.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Spec v0.6.0 adds three @events features: getExperimentFlag, trackEvent and trackExposureEvent. It also adds the Create the SDK client with events enabled step. The Rust SDK had no event tracking, so 5 of the 7 scenarios failed with "The SDK does not implement the step". This pushes f2963cc, which implements the features in the SDK, modelled on the Python and Go clients:
Event processor (src/flagsmith/events.rs). It is enabled with FlagsmithOptions { enable_events: true, events_api_url, .. }. A background thread buffers events and POSTs them to <events_api_url>v1/events. It sends on a timer (10s default), when the buffer is full, on Flagsmith::flush_events(), and when the client is dropped. Each event carries sdk_version metadata and a millisecond timestamp. The X-Environment-Key and Flagsmith-SDK-User-Agent headers are set. If the same exposure is tracked again while the first is still buffered, only one is sent. Unavailable responses (network error, 408, 429, 5xx) keep the batch for the next timed flush. Other error responses drop it.
Flagsmith::get_experiment_flag(feature, identifier, traits) resolves the identity's flag. It records a $flag_exposure (value = variant, metadata = experiment_id, with the identity's traits) only when the flag is enabled, isn't a default flag, and the identity is in_experiment with a variant.
Flagsmith::track_event rejects names starting with $. Flagsmith::track_exposure_event requires an identifier. All three methods return a client error when events are not enabled.
Flag has new variant and experiment fields, parsed from the remote identities response. Local evaluation does not provide them. Code that builds a Flag with a struct literal now needs ..Default::default().
sdk-spec/steps.rs connects the 4 new steps directly to these SDK methods.
Unit and integration tests cover the event payload, exposure de-duplication, buffer overflow, flushing (timer, full buffer, explicit and on drop), retry and drop handling, and when an exposure is or isn't recorded. cargo test --all-features --workspace passes, and so does cargo fmt --check. I also ran the v0.6.0 spec locally against the SDK image built with the repo's Dockerfile (Rust 1.86), and all 7 scenarios passed.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔇 Additional comments: 3
src/flagsmith/events.rs-270-274: 1
270-274: Minor · Potential issue · Heavy lift
⚠️Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.
A transport error retains the entire POST batch without an event idempotency key visible in the payload, so a timeout after server acceptance may replay custom events.
A later flush can double-count the conversion.
This can occur when: The events API processes a conversion POST, but its response is lost or arrives after the client timeout.
sdk-spec/steps.rs-101-107: 1
101-107: Minor · Potential issue · Quick win
⚠️Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.
The new spec event-producing steps return after enqueueing, without calling flush_events; the experiment and explicit-exposure steps use the same asynchronous processor.
Spec assertions intermittently observe no request even though the step returned success.
This can occur when: The v0.6 spec runner checks its mock events endpoint immediately after a step returns, before the default flush interval or client drop.
src/flagsmith/events.rs-70-75: 1
70-75: Minor · Potential issue · Quick win
⚠️Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.
Exposure deduplication keys omit metadata.experiment_id, although get_experiment_flag records that ID. Equal feature, identity, and variant values from different experiments can collapse into one event.
The second experiment receives no exposure record.
This can occur when: An identity sees the same variant on a feature in two successive experiments before the buffer flushes.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: bda0ea3c-e0ed-43bb-a1b6-b5b7d462055b
Commits
Reviewing files that changed from the base of the PR and between 1d1a2bb and f2963cc.
Files selected for processing: 7
.github/workflows/sdk-spec.yml
sdk-spec/Cargo.toml
sdk-spec/steps.rs
src/flagsmith/events.rs
src/flagsmith/mod.rs
src/flagsmith/models.rs
tests/integration_test.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Bound the event queue to the configured buffer size.
The channel at line 184 is unbounded. While the worker blocks in a slow successful flush, callers keep queuing events. If events arrive faster than max_buffer_size per flush, the queue grows until memory is exhausted. Bound the queue and drop events when it is full.
🐛 Suggested fix
- let (tx, rx) = flume::unbounded();+ let (tx, rx) = flume::bounded(max_buffer_size.max(1));
fn send(&self, event: Event) {
- if self.tx.send(Message::Track(event)).is_err() {- warn!("Event processor has stopped; dropped an event");- }+ match self.tx.try_send(Message::Track(event)) {+ Ok(()) => {}+ Err(flume::TrySendError::Full(_)) => warn!("Event queue is full; dropped an event"),+ Err(flume::TrySendError::Disconnected(_)) => {+ warn!("Event processor has stopped; dropped an event")+ }+ }
}
Retry held events on the elapsed interval, not only on Timeout.
A failed send sets held, and the timed flush runs only on Timeout. flume returns queued messages before reporting a timeout, so a continuous backlog suppresses it. Held events stay unsent and can be evicted, even after the API recovers. Also check the interval in the Track arm.
Skip exposure recording when the identifier is blank in get_experiment_flag.
get_experiment_flag records an exposure with identifier: Some(identifier.to_string()) and does not reject a blank identifier. The public track_exposure_event rejects a blank identifier, but get_experiment_flag calls the event processor directly and does not use that method. When a blank identifier returns an enrolled, enabled flag with a variant, the method enqueues an exposure with an empty identifier. The SDK's own exposure method refuses that input.
Suggested fix
let exposure = match (&flag.experiment, &flag.variant) {
+ _ if identifier.trim().is_empty() => Err("the identifier is blank"),
_ if flag.is_default => Err("the flag is a default flag"),
Implements the experimentation features SDK spec v0.6.0 requires:
- `enable_events` starts an event processor that buffers events and
sends them to Flagsmith's events API in batches.
- `get_experiment_flag` resolves a flag for an identity and records a
`$flag_exposure` when the identity is enrolled in a running experiment.
- `track_event` and `track_exposure_event` record events directly.
- `Flag` exposes the `variant` and `experiment` served by remote
identity evaluation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f2963cc)
Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.
You can manually request rebase by checking the rebase/retry box above.
⚠️Warning: custom changes will be lost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openhandsPicked up by OpenHandssdk-specBumps of the Flagsmith SDK behavioural spec
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
v0.3.0→v0.7.0v0.3.0→v0.7.0Release Notes
Flagsmith/sdk-spec
v0.7.0Compare Source
What's Changed
New Contributors
Full Changelog: Flagsmith/sdk-spec@v0.6.0...v0.7.0
v0.6.0Compare Source
What's Changed
New Contributors
Full Changelog: Flagsmith/sdk-spec@v0.5.1...v0.6.0
v0.5.1Compare Source
What's Changed
Full Changelog: Flagsmith/sdk-spec@v0.5.0...v0.5.1
v0.5.0Compare Source
What's Changed
Full Changelog: Flagsmith/sdk-spec@v0.4.0...v0.5.0
v0.4.0Compare Source
What's Changed
New Contributors
Full Changelog: Flagsmith/sdk-spec@v0.3.0...v0.4.0
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR was generated by Mend Renovate. View the repository job log.