open-feature / open-feature/flagd
[BUG] undefined behavior when using invalid types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 997
- Forks
- 136
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 11
Description
Observed behavior
I'm trying to sync feature flags from an API that returns array values for some flags (e.g., ["CA", "NY", "TX"] for enabled states).
When flagd v0.11.6 loads a configuration containing flags with array-type variant values, it:
- Logs a validation warning that arrays are not a supported type
- Continues to serve the flags despite the validation error
- Returns non-deterministic values from other unrelated flags in the configuration when querying the array-type flags
For example, when querying a flag chocolate_enabled_states with an empty array value [], successive queries return:
- First query: boolValue: true with metadata from a completely different flag ("Enable Thrive Gives for autoship customers")
- Second query: stringValue: "Our Freshness Guarantee" with metadata from yet another unrelated flag ("Fresh product banner title")
- Third query: null values
The values and metadata returned appear to be bleeding over from other flags in the same configuration file.
❯ curl -X POST "https://flagd.dev.trellis.thrivemarketinternal.com/flagd.evaluation.v1.Service/ResolveAll" -d '{"context":{}}' -H "Content-Type: application/json" | jq | grep states -A10
"chocolate_enabled_states": {
"reason": "STATIC",
"variant": "default",
"stringValue": "https://img.thrivemarket.com/",
"metadata": {
"description": "Secure URL for media assets",
"source": "magento-cms",
"version": "1.0.0"
}
},
"chocolate_shipping_enabled": {
❯ curl -X POST "https://flagd.dev.trellis.thrivemarketinternal.com/flagd.evaluation.v1.Service/ResolveAll" -d '{"context":{}}' -H "Content-Type: application/json" | jq | grep states -A10
"chocolate_enabled_states": {
"reason": "STATIC",
"variant": "default",
"stringValue": "America/Los_Angeles",
"metadata": {
"description": "Store timezone",
"source": "magento-cms",
"version": "1.0.0"
}
},
"chocolate_shipping_enabled": {
Expected Behavior
Expected Behavior
One of the following should occur when flagd encounters array-type variant values:
- Best: Support arrays as a first-class variant type (like boolean, string, number, object) #1673
- Acceptable: Return a consistent error response for the invalid flag type, not random values from other flags
Array-type flags should never return values or metadata from unrelated flags in the configuration.
Steps to reproduce
- Create a test flag configuration with array values:
Create file: minimal-repro-extended.json (attached)
- Run flagd with the configuration:
docker run -p 8013:8013 -v $(pwd)/minimal-repro-extended.json:/flags.json \
ghcr.io/open-feature/flagd:v0.11.6 start --uri file:./flags.json
- Observe validation warnings in logs:
docker logs <container-id> 2>&1 | grep warn
You'll see:
warn flag definition does not conform to the schema; validation errors:
1:flags.array_flag_1: Must validate one and only one schema (oneOf)
2:flags.array_flag_1.variants.default: Invalid type. Expected: boolean, given: array
3:flags.array_flag_1: Must validate all the schemas (allOf)
- Query the array flag multiple times:
for i in {1..10}; do
curl -s -X POST "http://localhost:8013/flagd.evaluation.v1.Service/ResolveAll" \
-d '{"context":{}}' \
-H "Content-Type: application/json" | \
jq '.flags.array_flag_1 | {boolValue, stringValue, intValue, description: .metadata.description}'
done
- Observe non-deterministic results:
Different queries return different values and metadata from other flags in the configuration.
docker-compose-test.yaml
MINIMAL_REPRO_README.md
minimal-repro-extended.json
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with minimal-repro-extended.json and the ResolveAll endpoint, then run the Docker reproduction and repeat the array-flag queries. Trace how the invalid array variant is handled after schema validation; done means array flags either have supported, consistent results or return a consistent error without values or metadata leaking from other flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100