Skip to content

[BUG] Feature flags synchronization failure if file with feature flags is removed and restored #1876

Closed

Description

@ElAdriano

Observed behavior

While trying to evaluate feature flags using /ofrep/v1/evaluate/flags endpoint, I encountered an issue related to feature flags synchronization. In standard way of defined flags management, if definition of given flag changes (like its default variant, metadata etc.), appropriate event is being raised and its centralized state is updated.

Example (clarification for what I'm referring to in the beginning)
I have defined following flag inside feature_flags.json file:

{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		}
	}
}

When I evaluate flags (i.e. call mentioned endpoint) first, I receive following response:

C:\>curl -X POST http://localhost:8016/ofrep/v1/evaluate/flags
{"flags":[{"value":false,"key":"myFeature","reason":"STATIC","variant":"off","metadata":{"description":"Some description"}}],"metadata":{}}

After altering feature flag in file, I see its state has changed.
feature_flags.json:

{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "on", // <- changed from "off" to "on"
			"metadata": {
				"description": "Some description"
			}
		}
	}
}

Response (flag value changed to "on" variant):

C:\>curl -X POST http://localhost:8016/ofrep/v1/evaluate/flags
{"flags":[{"value":true,"key":"myFeature","reason":"STATIC","variant":"on","metadata":{"description":"Some description"}}],"metadata":{}}

However, if I remove mentioned feature_flags.json file and restore it back, synchronization between running flagd and feature flag source breaks, making ofrep endpoint response unchanged (assuming You have just one flags definition source)

Before removing and restoring feature_flag.json file back

feature_flags.json file content:

{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "on",
			"metadata": {
				"description": "Some description"
			}
		}
	}
}

Ofrep endpoint response:

C:\>curl -X POST http://localhost:8016/ofrep/v1/evaluate/flags
{"flags":[{"value":true,"key":"myFeature","reason":"STATIC","variant":"on","metadata":{"description":"Some description"}}],"metadata":{}}

After removing and restoring feature_flag.json file back, I defined 2 feature flags in feature_flag.json file:

{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		},
		"myFeature2": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		}
	}
}

Ofrep endpoint response:

C:\>curl -X POST http://localhost:8016/ofrep/v1/evaluate/flags
{"flags":[{"value":true,"key":"myFeature","reason":"STATIC","variant":"on","metadata":{"description":"Some description"}}],"metadata":{}}

Seems like this removing and restoring file procedure, removes a source watcher permanently, so flagd cannot track/keep in sync defined flag state.

Expected Behavior

Removing and restoring file with feature flags definitions shouldn't break synchronization between flagd and sources. If such situation occurs, file watcher should be rebuilt, making sure that managed flags are always in sync with specified sources

Steps to reproduce

Prerequisites:

  1. Create "feature_flags.json" file with following content:
{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		}
	}
}
  1. Start flagd process using following command:
    flagd.exe start --debug --uri file:C:\dev\misc\github\feature_flags.json --ofrep-port 8016 --sync-port 8015 --port 8013 --management-port 8014
  2. Send a POST request to /ofrep/v1/evaluate/flags endpoint to evaluate defined feature flags
  3. Remove created feature_flags.json file and restore it back (delete and use ctrl+z right away)
  4. Define new feature flag within feature_flags.json - see example:
{
	"flags": {
		"myFeature": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		},
		"myFeature2": {
			"state": "ENABLED",
			"variants": {
				"on": true,
				"off": false
			},
			"defaultVariant": "off",
			"metadata": {
				"description": "Some description"
			}
		}
	}
}
  1. Send a POST request to /ofrep/v1/evaluate/flags endpoint to evaluate defined feature flags
  2. Compare responses received in steps 3 and 6. Response for request sent in step 6 should contain information regarding both myFeature and myFeature2 flag, whereas response from step 3 should provide information about myFeature flag only

Activity

  1. added
    bug
    Needs Triage
    on Feb 24, 2026
  2. beeme1mr commented on Feb 24, 2026

    @beeme1mr
    Member

    Hey @ElAdriano, thanks for the issue. I'll leave this open and add a "Help Wanted" badge. I see this is a low priority, since flagd would fail if you tried to start the daemon without the file. It's not recommended to remove a file that's being watched while flagd is running, or it could lead to undefined behavior. FYI @toddbaert

  3. added
    help wanted
    on Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Triagebughelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions