Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: allow custom seed when using targetingKey override for fractional op #1266

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

colebaileygit
Copy link
Contributor

@colebaileygit colebaileygit commented Mar 30, 2024

This PR

  • no longer injects flagKey as seed for fractional op when user has provided custom targeting
  • updates schema to allow cat and other operations so that custom targeting can be properly seeded

Related Issues

#1264

Notes

Follow-up Tasks

How to test

# unit tests
make test

# gherkin tests
./bin/flagd start -f file:test-harness/flags/testing-flags.json -f file:test-harness/flags/custom-ops.json -f file:test-harness/flags/evaluator-refs.json -f file:test-harness/flags/zero-flags.json
make flagd-integration-test

@colebaileygit colebaileygit requested a review from a team as a code owner March 30, 2024 20:22
@colebaileygit colebaileygit changed the title add optional custom seed override for fractional op feat: add optional custom seed override for fractional op Mar 30, 2024
Copy link

netlify bot commented Mar 30, 2024

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 6e989c4
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/6614592e6ba4c20008104fe7

@colebaileygit colebaileygit changed the title feat: add optional custom seed override for fractional op feat: allow custom seed when using targetingKey override for fractional op Apr 1, 2024
@Kavindu-Dodan Kavindu-Dodan changed the title feat: allow custom seed when using targetingKey override for fractional op feat!: allow custom seed when using targetingKey override for fractional op Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.51%. Comparing base (1c530ab) to head (6e989c4).
Report is 46 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1266      +/-   ##
==========================================
+ Coverage   73.69%   77.51%   +3.82%     
==========================================
  Files          32       20      -12     
  Lines        3140     1610    -1530     
==========================================
- Hits         2314     1248    -1066     
+ Misses        717      281     -436     
+ Partials      109       81      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kavindu-Dodan
Copy link
Contributor

@colebaileygit could you please update the documentation [1]. We should document the ability to customize the distribution key (ex:- using cat or any other valid string operation). And include not on this change.

[1] - https://github.com/open-feature/flagd/blob/main/docs/reference/custom-operations/fractional-operation.md

@colebaileygit
Copy link
Contributor Author

colebaileygit commented Apr 3, 2024

@colebaileygit could you please update the documentation [1]. We should document the ability to customize the distribution key (ex:- using cat or any other valid string operation). And include not on this change.

[1] - https://github.com/open-feature/flagd/blob/main/docs/reference/custom-operations/fractional-operation.md

Added 👍

@Kavindu-Dodan
Copy link
Contributor

once open-feature/flagd-schemas#136 is merged, we must update the submodule to the latest release of the schema.

beeme1mr pushed a commit to open-feature/flagd-schemas that referenced this pull request Apr 8, 2024
<!-- Please use this template for your pull request. -->
<!-- Please use the sections that you need and delete other sections -->

## This PR
<!-- add the description of the PR here -->

- updates fractional schema to accept complex rules as first argument to
override targeting so that we can support using `cat` and other rules to
provide custom seeds to randomisation

### Related Issues
<!-- add here the GitHub issue that this PR resolves if applicable -->

open-feature/flagd#1264
resolves open-feature/flagd#1265

### Notes
<!-- any additional notes for this PR -->

### Follow-up Tasks
<!-- anything that is related to this PR but not done here should be
noted under this section -->
<!-- if there is a need for a new issue, please link it here -->

### How to test
<!-- if applicable, add testing instructions under this section -->

see open-feature/flagd#1266

---------

Signed-off-by: Cole Bailey <[email protected]>
Signed-off-by: Kavindu Dodanduwa <[email protected]>
Co-authored-by: Kavindu Dodanduwa <[email protected]>
@Kavindu-Dodan
Copy link
Contributor

@colebaileygit I have updated this PR with the latest submodules as well as Go dependencies. All checks are green. Planning to merge this tomorrow :)

@toddbaert
Copy link
Member

Great solution and effort @colebaileygit . Thanks for your diligence.

@Kavindu-Dodan @beeme1mr I guess we need to update the in-process impls ASAP?

@Kavindu-Dodan
Copy link
Contributor

Great solution and effort @colebaileygit . Thanks for your diligence.

@Kavindu-Dodan @beeme1mr I guess we need to update the in-process impls ASAP?

Yeah, for Go SDK, it's a matter of using the latest flagd core with the next release.

Otherwise, we already have PRs for Java [1] & Python [2]. I think JS needs to be taken care of.

[1] - open-feature/java-sdk-contrib#737
[2] - open-feature/python-sdk-contrib#74

@Kavindu-Dodan Kavindu-Dodan merged commit f62bc72 into open-feature:main Apr 9, 2024
15 checks passed
toddbaert added a commit that referenced this pull request Apr 10, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.10.0</summary>

##
[0.10.0](flagd/v0.9.2...flagd/v0.10.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
* This is a breaking change only to the extent that it changes the
assignment of evaluated flag values.
Previously, flagd's `fractional` op would internally concatenate any
specified bucketing property with the `flag-key`.
This improved apparent "randomness" by reducing the chances that users
were assigned a bucket of the same ordinality across multiple flags.
However, sometimes it's desireable to have such predictibility, so now
**flagd will use the bucketing value as is**.
If you are specifying a bucketing value in a `fractional` rule, and want
to maintain the previous assignments, you can do this concatenation
manually:
`{ "var": "user.name" }` => `{"cat": [{ "var": "$flagd.flagKey" }, {
"var": "user.name" }]}`.
      This will result in the same assignment as before.
Please note, that if you do not specify a bucketing key at all (the
shorthand version of the `fractional` op), flagd still uses a
concatentation of the `flag-key` and `targetingKey` as before; this
behavior has not changed.

### 🐛 Bug Fixes

* **deps:** update module github.com/open-feature/flagd/core to v0.8.2
([#1255](#1255))
([9005089](9005089))


### ✨ New Features

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
([f62bc72](f62bc72))


### 🧹 Chore

* refactor evaluation core
([#1259](#1259))
([0e6604c](0e6604c))
* update go deps
([#1279](#1279))
([219789f](219789f))
</details>

<details><summary>flagd-proxy: 0.6.0</summary>

##
[0.6.0](flagd-proxy/v0.5.2...flagd-proxy/v0.6.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
* This is a breaking change only to the extent that it changes the
assignment of evaluated flag values.
Previously, flagd's `fractional` op would internally concatenate any
specified bucketing property with the `flag-key`.
This improved apparent "randomness" by reducing the chances that users
were assigned a bucket of the same ordinality across multiple flags.
However, sometimes it's desireable to have such predictibility, so now
**flagd will use the bucketing value as is**.
If you are specifying a bucketing value in a `fractional` rule, and want
to maintain the previous assignments, you can do this concatenation
manually:
`{ "var": "user.name" }` => `{"cat": [{ "var": "$flagd.flagKey" }, {
"var": "user.name" }]}`.
      This will result in the same assignment as before.
Please note, that if you do not specify a bucketing key at all (the
shorthand version of the `fractional` op), flagd still uses a
concatentation of the `flag-key` and `targetingKey` as before; this
behavior has not changed.

### 🐛 Bug Fixes

* **deps:** update module github.com/open-feature/flagd/core to v0.8.2
([#1255](#1255))
([9005089](9005089))


### ✨ New Features

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
([f62bc72](f62bc72))


### 🧹 Chore

* update go deps
([#1279](#1279))
([219789f](219789f))
</details>

<details><summary>core: 0.9.0</summary>

##
[0.9.0](core/v0.8.2...core/v0.9.0)
(2024-04-10)


### ⚠ BREAKING CHANGES

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
* This is a breaking change only to the extent that it changes the
assignment of evaluated flag values.
Previously, flagd's `fractional` op would internally concatenate any
specified bucketing property with the `flag-key`.
This improved apparent "randomness" by reducing the chances that users
were assigned a bucket of the same ordinality across multiple flags.
However, sometimes it's desireable to have such predictibility, so now
**flagd will use the bucketing value as is**.
If you are specifying a bucketing value in a `fractional` rule, and want
to maintain the previous assignments, you can do this concatenation
manually:
`{ "var": "user.name" }` => `{"cat": [{ "var": "$flagd.flagKey" }, {
"var": "user.name" }]}`.
      This will result in the same assignment as before.
Please note, that if you do not specify a bucketing key at all (the
shorthand version of the `fractional` op), flagd still uses a
concatentation of the `flag-key` and `targetingKey` as before; this
behavior has not changed.

### ✨ New Features

* allow custom seed when using targetingKey override for fractional op
([#1266](#1266))
([f62bc72](f62bc72))


### 🧹 Chore

* refactor evaluation core
([#1259](#1259))
([0e6604c](0e6604c))
* update go deps
([#1279](#1279))
([219789f](219789f))
* wire evaluation ctx to store methods
([#1273](#1273))
([0075932](0075932))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Signed-off-by: OpenFeature Bot <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Todd Baert <[email protected]>
toddbaert added a commit that referenced this pull request Apr 16, 2024
Update publicly served schema (flagd.dev)

Specifically this supports
[enhancements](#1266) from
@colebaileygit

Signed-off-by: Todd Baert <[email protected]>
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.

4 participants