Flagsmith / Flagsmith/flagsmith

OFREP Bulk flag evaluation (Core API)

Open
#8,437 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 13h
Merged PRs (30d)
121

Description

In order to implement the [OFREP specification](https://openfeature.dev/docs/reference/other-technologies/ofrep/openapi), our Core API needs a new endpoint that evaluates all flags in an environment given a set of identity traits. The Edge API counterpart is [Flagsmith/edge-api#711](https://github.com/Flagsmith/edge-api/issues/711).

An interpretation of the specification to our data model is as the following example:

(request)
```http
POST /ofrep/v1/evaluate/flags HTTP/1.1
Host: {flagsmith_host}
X-API-Key: {client_side_environment_key}
Content-Type: application/json

{
"context": {
"targetingKey": "{identity.identifier}",
"trait1": "value1",
"trait2": "value2"
}
}
```

(response)
```http
HTTP/1.1 200 OK
Content-Type: application/json
ETag: "{etag}"

{
"flags": [
{
"key": "{feature.name}",
"value": "{feature_state.feature_state_value}",
"reason": "TARGETING_MATCH"
},
{
"key": "{feature.name}",
"value": {feature_state.enabled},
"reason": "STATIC"
},
{
"key": "{feature.name}",
"value": "{multivariate_feature_option.value}",
"reason": "SPLIT",
"variant": "{multivariate_feature_option.key}"
}
],
"metadata": {
"version": "{environment.updated_at}"
}
}
```

## Acceptance criteria

- Our API exposes a new endpoint `POST /ofrep/v1/evaluate/flags` compliant to the [OFREP specification](https://openfeature.dev/docs/reference/other-technologies/ofrep/openapi#tag/OFREP-Core/operation/evaluateFlagsBulk). As such, the endpoint:
- Responds with an `ETag` header derived from the response body.
- Accepts an `If-None-Match` header which can lead to a `304 Not Modified` response.
- Serves each flag's value as its remote configuration value, falling back to the flag's enabled state when no value is set.
- Reports each flag's evaluation reason using the vocabulary OFREP defines.
- Is billed similarly to other billed endpoints.
- Persists the identity and its traits on the same terms as identity flag evaluation.

> [!IMPORTANT]
> Server-Sent Events stream lookups are out of scope for this issue.

Contributor guide

Open the contributing guide

Research direction

Start with the existing identity flag evaluation endpoint and other billed endpoints, then compare their behavior with the OFREP evaluateFlagsBulk specification. Implement and test POST /ofrep/v1/evaluate/flags so it covers bulk evaluation, persistence, billing, ETag and conditional responses, with SSE stream lookups excluded; done means all acceptance criteria are met.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.