You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/flag-definitions.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,9 +122,10 @@ Example of an invalid configuration:
122
122
123
123
### Default Variant
124
124
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.
128
129
129
130
Example:
130
131
@@ -147,6 +148,16 @@ Example:
147
148
"defaultVariant": "red"
148
149
```
149
150
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
+
150
161
Example of an invalid configuration:
151
162
152
163
```json
@@ -172,6 +183,12 @@ One exception to the above is that rules may return `true` or `false` which will
172
183
If a null value is returned by the targeting rule, the `defaultVariant` is used.
173
184
This can be useful for conditionally "exiting" targeting rules and falling back to the default (in this case the returned reason will be `DEFAULT`).
174
185
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.
175
192
176
193
See [Boolean Variant Shorthand](#boolean-variant-shorthand).
0 commit comments