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: support flag metadata #1476

Merged
merged 13 commits into from
Jan 15, 2025
Merged

Conversation

aasifkhan7
Copy link
Contributor

@aasifkhan7 aasifkhan7 commented Dec 16, 2024

This PR

  • Adds functionality to return flag metadata as part of the response.

Related Issues

Fixes #1464

Notes

This PR ensures that flag metadata is included and handled correctly in responses.

@aasifkhan7 aasifkhan7 requested a review from a team as a code owner December 16, 2024 21:43
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 16, 2024
Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 534e07e
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/67875e4446a4f90008f3e18f

@aasifkhan7 aasifkhan7 changed the title return flag metadata as well feat: return flag metadata as well Dec 17, 2024
@aasifkhan7 aasifkhan7 force-pushed the feat/flag-metadata branch 3 times, most recently from 3b6e501 to c55537f Compare December 17, 2024 05:20
@beeme1mr
Copy link
Member

Hey @aasifkhan7, I tested this locally and wasn't able to see flag metadata returned as a response.

Here's the flag configuration I was using:

{
  "flags": {
    "myBoolFlag": {
      "state": "ENABLED",
      "variants": {
        "on": true,
        "off": false
      },
      "defaultVariant": "on"
    }
  },
  "metadata": {
    "id": "test",
    "version": "1"
  }
}

Here are the test evaluations I tried:

curl -X POST "localhost:8013/flagd.evaluation.v1.Service/ResolveBoolean" -d '{"flagKey":"myBoolFlag","context":{}}' -H "Content-Type: application/json"

and

curl -X POST 'http://localhost:8016/ofrep/v1/evaluate/flags'

Please map the id and version to flagSetId and flagSetVersion respectively in the flag metadata. That will set us up nicely once this spec PR is merged. Thanks!

@aasifkhan7
Copy link
Contributor Author

Hi @beeme1mr,

I've updated the commit to include the setting of flagSetId and flagSetVersion in the flag metadata as well. Could you please re-review the changes?

Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aasifkhan7 nice job so far!

OFREP works as expected:

curl -X POST 'http://localhost:8016/ofrep/v1/evaluate/flags' | jq

{
  "flags": [
    {
      "value": 1,
      "key": "myIntFlag",
      "reason": "STATIC",
      "variant": "one",
      "metadata": {
        "flagSetId": "test",
        "flagSetVersion": "1"
      },
    ...
    }
  ]
}
curl -X POST "localhost:8013/flagd.evaluation.v1.Service/ResolveBoolean" -d '{"flagKey":"myBoolFlag","context":{}}' -H "Content-Type: application/json" | jq


{
  "value": true,
  "reason": "STATIC",
  "variant": "on",
  "metadata": {
    "flagSetId": "test",
    "flagSetVersion": "1"
  }
}

I left some comments - I also think we need some basic test coverage for this, but nice job!

core/pkg/store/flags.go Outdated Show resolved Hide resolved
@apodgorbunschih
Copy link

👋 Hello folks,
@aasifkhan7 I had a question regarding the following MR.
Accordingly to that spec https://github.com/open-feature/flagd-schemas/pull/173/files the Metadata can be "Any additional key/value pair with value of type boolean, string, or number.". However in this MR the Metadata have a defined structure. Or this is something else and I am confusing 2 things ? 🤔 🙏
Thanks in advance!

@aasifkhan7
Copy link
Contributor Author

👋 Hello folks, @aasifkhan7 I had a question regarding the following MR. Accordingly to that spec https://github.com/open-feature/flagd-schemas/pull/173/files the Metadata can be "Any additional key/value pair with value of type boolean, string, or number.". However in this MR the Metadata have a defined structure. Or this is something else and I am confusing 2 things ? 🤔 🙏 Thanks in advance!

@apodgorbunschih I've updated the PR to handle any fields that come in metadata.

Please re-review @beeme1mr @toddbaert

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll manually test this. Could you please also ensure there are tests in the PR. Thanks!

core/pkg/evaluator/json_model.go Outdated Show resolved Hide resolved
core/pkg/model/flag.go Outdated Show resolved Hide resolved
core/pkg/store/flags.go Outdated Show resolved Hide resolved
@beeme1mr
Copy link
Member

beeme1mr commented Jan 7, 2025

I've also addressed the unrelated license compliance issue.

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually tested it it nearly works. Please adjust the merge priority logic and add some tests. We should be good to go after that. Thanks!

core/pkg/evaluator/json.go Outdated Show resolved Hide resolved
@beeme1mr beeme1mr changed the title feat: return flag metadata as well feat: support flag metadata Jan 9, 2025
@toddbaert
Copy link
Member

Hey @aasifkhan7 ! This seems very close to done, with the exception of some tests. Are you able to finish any time soon? If not, I can add the tests onto your existing work (you will still appear as a committer).

Let me know!

@aasifkhan7
Copy link
Contributor Author

@toddbaert , sorry for the delay, I got busy the last few weeks.

I'll add the tests. Thanks.

@aasifkhan7
Copy link
Contributor Author

I've added a few test cases @beeme1mr @toddbaert . Please take a look.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 15, 2025
@toddbaert toddbaert requested a review from beeme1mr January 15, 2025 18:35
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually tested both the gRPC and HTTP endpoints, looks good. Tests also look good.

Thanks so much for helping with this @aasifkhan7 and working through it with us! This will be extremely helpful for adding more powerful telemetry for flagd users.

@toddbaert toddbaert merged commit 13fbbad into open-feature:main Jan 15, 2025
14 checks passed
@github-actions github-actions bot mentioned this pull request Jan 15, 2025
toddbaert pushed a commit that referenced this pull request Jan 15, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.11.6</summary>

##
[0.11.6](flagd/v0.11.5...flagd/v0.11.6)
(2025-01-15)


### 🐛 Bug Fixes

* **deps:** update module
buf.build/gen/go/open-feature/flagd/connectrpc/go to
v1.17.0-20241220192239-696330adaff0.1
([#1488](#1488))
([8e09457](8e09457))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/connectrpc/go to
v1.18.1-20241220192239-696330adaff0.1
([#1506](#1506))
([b868194](b868194))
* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.1
([#1489](#1489))
([53add83](53add83))
* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.2
([#1492](#1492))
([9f1d94a](9f1d94a))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/protocolbuffers/go to
v1.36.0-20241220192239-696330adaff0.1
([#1490](#1490))
([6edce72](6edce72))
* **deps:** update module github.com/mattn/go-colorable to v0.1.14
([#1508](#1508))
([87727f7](87727f7))
* **deps:** update module github.com/open-feature/flagd/core to v0.10.5
([#1482](#1482))
([ce48cb7](ce48cb7))
* **deps:** update module golang.org/x/net to v0.33.0 [security]
([#1486](#1486))
([4764077](4764077))
* **deps:** update module golang.org/x/net to v0.34.0
([#1498](#1498))
([7584f95](7584f95))
* **deps:** update module google.golang.org/grpc to v1.69.2
([#1484](#1484))
([6b40ad3](6b40ad3))
* **deps:** update module google.golang.org/grpc to v1.69.4
([#1510](#1510))
([76d6353](76d6353))
* **deps:** update module google.golang.org/protobuf to v1.36.1
([#1491](#1491))
([2c729a7](2c729a7))
* **deps:** update opentelemetry-go monorepo
([#1470](#1470))
([26b0b1a](26b0b1a))


### ✨ New Features

* add ssl support to sync service
([#1479](#1479))
([#1501](#1501))
([d50fcc8](d50fcc8))
</details>

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

##
[0.6.9](flagd-proxy/v0.6.8...flagd-proxy/v0.6.9)
(2025-01-15)


### 🐛 Bug Fixes

* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.1
([#1489](#1489))
([53add83](53add83))
* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.2
([#1492](#1492))
([9f1d94a](9f1d94a))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/protocolbuffers/go to
v1.36.0-20241220192239-696330adaff0.1
([#1490](#1490))
([6edce72](6edce72))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/protocolbuffers/go to
v1.36.2-20241220192239-696330adaff0.1
([#1502](#1502))
([426c36e](426c36e))
* **deps:** update module github.com/mattn/go-colorable to v0.1.14
([#1508](#1508))
([87727f7](87727f7))
* **deps:** update module github.com/open-feature/flagd/core to v0.10.5
([#1482](#1482))
([ce48cb7](ce48cb7))
* **deps:** update module golang.org/x/net to v0.33.0 [security]
([#1486](#1486))
([4764077](4764077))
* **deps:** update module golang.org/x/net to v0.34.0
([#1498](#1498))
([7584f95](7584f95))
* **deps:** update module google.golang.org/grpc to v1.69.2
([#1484](#1484))
([6b40ad3](6b40ad3))
* **deps:** update module google.golang.org/grpc to v1.69.4
([#1510](#1510))
([76d6353](76d6353))
* **deps:** update opentelemetry-go monorepo
([#1470](#1470))
([26b0b1a](26b0b1a))
</details>

<details><summary>core: 0.10.6</summary>

##
[0.10.6](core/v0.10.5...core/v0.10.6)
(2025-01-15)


### 🐛 Bug Fixes

* **deps:** update github.com/open-feature/flagd-schemas digest to
37baa2c ([#1499](#1499))
([1a853f7](1a853f7))
* **deps:** update github.com/open-feature/flagd-schemas digest to
b81a56e ([#1391](#1391))
([6a3d8ac](6a3d8ac))
* **deps:** update golang.org/x/exp digest to 7588d65
([#1495](#1495))
([242e594](242e594))
* **deps:** update golang.org/x/exp digest to b2144cd
([#1320](#1320))
([a692b00](a692b00))
* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.1
([#1489](#1489))
([53add83](53add83))
* **deps:** update module buf.build/gen/go/open-feature/flagd/grpc/go to
v1.5.1-20241220192239-696330adaff0.2
([#1492](#1492))
([9f1d94a](9f1d94a))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/protocolbuffers/go to
v1.36.0-20241220192239-696330adaff0.1
([#1490](#1490))
([6edce72](6edce72))
* **deps:** update module
buf.build/gen/go/open-feature/flagd/protocolbuffers/go to
v1.36.2-20241220192239-696330adaff0.1
([#1502](#1502))
([426c36e](426c36e))
* **deps:** update module connectrpc.com/connect to v1.18.1
([#1507](#1507))
([89d3259](89d3259))
* **deps:** update module github.com/diegoholiveira/jsonlogic/v3 to
v3.7.0 ([#1496](#1496))
([e1fe149](e1fe149))
* **deps:** update module github.com/diegoholiveira/jsonlogic/v3 to
v3.7.1 ([#1509](#1509))
([9d06812](9d06812))
* **deps:** update module golang.org/x/crypto to v0.32.0
([#1497](#1497))
([63a34d2](63a34d2))
* **deps:** update module google.golang.org/grpc to v1.69.2
([#1484](#1484))
([6b40ad3](6b40ad3))
* **deps:** update module google.golang.org/grpc to v1.69.4
([#1510](#1510))
([76d6353](76d6353))
* **deps:** update opentelemetry-go monorepo
([#1470](#1470))
([26b0b1a](26b0b1a))


### ✨ New Features

* add ssl support to sync service
([#1479](#1479))
([#1501](#1501))
([d50fcc8](d50fcc8))
* support flag metadata
([#1476](#1476))
([13fbbad](13fbbad))
</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]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update flagd RPC and OFREP to support metadata
4 participants