Skip to content

Threshold scopes ordering#8128

Draft
Prithpal-Sooriya wants to merge 2 commits intomainfrom
cursor/threshold-scopes-ordering-cb8a
Draft

Threshold scopes ordering#8128
Prithpal-Sooriya wants to merge 2 commits intomainfrom
cursor/threshold-scopes-ordering-cb8a

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Mar 6, 2026

Explanation

  • What is the current state of things and why does it need to change?
    The remote-feature-flag-controller's logic for selecting a threshold group could be influenced by the order of thresholdScope entries in the feature flag configuration. If the thresholdScope array was not sorted, the .find operation might pick a suboptimal or incorrect threshold group, leading to inconsistent feature flag evaluation.
  • What is the solution your changes offer and how does it work?
    This PR introduces a fix to ensure that thresholdScope entries are explicitly sorted by their scope.value in ascending order before the .find operation is performed. This guarantees that the lowest matching threshold is always selected, making the threshold group selection deterministic and independent of the input array's order.
  • Are there any changes whose purpose might not obvious to those unfamiliar with the domain?
    The sorting step ensures that even if the feature flag configuration provides threshold scopes in an arbitrary order (e.g., 1.0 before 0.1), the controller will consistently evaluate them as if they were ordered, picking the most appropriate (lowest matching) threshold.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Open in Web Open in Cursor 

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@cursor
Copy link

cursor bot commented Mar 6, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant