Skip to content

Commit 13ea4e8

Browse files
authored
Merge branch 'main' into 1842-feature-unified-flagd-evaluator-poc-javapython-reduced-maintenance-poc-and-reference
2 parents 4f4dc26 + 33774c7 commit 13ea4e8

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

docs/reference/flag-definitions.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ Example of an invalid configuration:
122122

123123
### Default Variant
124124

125-
`defaultVariant` is a **required** property.
126-
The value **must** match the name of one of the variants defined above.
127-
The default variant is always used unless a targeting rule explicitly overrides it.
125+
`defaultVariant` is an **optional** property.
126+
If `defaultVariant` is a string, its value **must** match the name of one of the variants defined above.
127+
The default variant is used unless a targeting rule explicitly overrides it.
128+
If `defaultVariant` is omitted or null, flagd providers will revert to the code default for the flag in question if targeting is not defined or falls through.
128129

129130
Example:
130131

@@ -147,6 +148,16 @@ Example:
147148
"defaultVariant": "red"
148149
```
149150

151+
Example of explicitly using the code default:
152+
153+
```json
154+
"variants": {
155+
"on": true,
156+
"off": false
157+
},
158+
"defaultVariant": null
159+
```
160+
150161
Example of an invalid configuration:
151162

152163
```json
@@ -172,6 +183,12 @@ One exception to the above is that rules may return `true` or `false` which will
172183
If a null value is returned by the targeting rule, the `defaultVariant` is used.
173184
This can be useful for conditionally "exiting" targeting rules and falling back to the default (in this case the returned reason will be `DEFAULT`).
174185
If an invalid variant is returned (not a string, `true`, or `false`, or a string that is not in the set of variants) the evaluation is considered erroneous.
186+
If `defaultVariant` is not defined or is `null`, and no variant is resolved from `targeting`, flagd providers will revert to the code default.
187+
188+
!!! note
189+
190+
When `defaultVariant` is omitted, and no variant is resolved from a rule, providers default by behaving as if the flag does not exist (`reason=ERROR` and `error=FLAG_NOT_FOUND`).
191+
This will be improved in upcoming versions, such that delegation to code default in this scenario will not be considered erroneous.
175192

176193
See [Boolean Variant Shorthand](#boolean-variant-shorthand).
177194

0 commit comments

Comments
 (0)