Skip to content

Bug (v2): Creating a Flag Resource with an invalid segment leads to inconsistencies #4748

Description

@markphelps

Filing on behalf of a user from our Discord: https://discord.com/channels/960634591000014878/1417514093354553505

In working with Flipt V2 I found that I can create a flag resource, but if I specfy a non-existent segment, the flag is created, but leads to odd errors.

$ curl -X POST -k http://localhost:8080/api/v2/environments/default/namespaces/default/resources -d '{
    "key": "flag1",
    "revision": "1.0",
    "payload": {
        "@type": "flipt.core.Flag",
        "type": "BOOLEAN_FLAG_TYPE",
        "name": "flag1",
        "enabled": true,
        "description": "feature flag 1",
        "rollouts": [
            {
                "type": "SEGMENT_ROLLOUT_TYPE",
                "description": "enabled for fizzbuzz",
                "segment": {
                    "key": "fizz",
                    "value": true,
                    "segmentOperator": "OR_SEGMENT_OPERATOR",
                    "segments": ["buzz"]
                }
            }
        ]
    }
}'

I can fetch the flag using the API and see it in the UI.

But the snapshot doesn't get created right which of course means evaluation breaks:

 curl -k http://localhost:8080/client/v2/environments/:environmentKey/namespaces/default/snapshot | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    93  100    93    0     0   101k      0 --:--:-- --:--:-- --:--:-- 93000
{
  "code": 5,
  "message": "evaluation snapshot for namespace \"default\" not found",
  "details": []
}

Errors are logged:

2025-09-16T08:57:08-05:00    ERROR    updating snapshot    {"server": "grpc", "error": "flag default/flag1 rule 1 references unknown segment "buzz"", "environment": "default"}
2025-09-16T08:57:08-05:00    ERROR    while updating subscriber    {"server": "grpc", "git_storage_type": "memory", "error": "flag default/flag1 rule 1 references unknown segment "buzz""}

And the UI gets unhappy as well.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Done
    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions