Skip to content

Commit 28bffa5

Browse files
authored
fix(flipt): return the correct default value when provided in Flipt (#1052)
Signed-off-by: Roman Dmytrenko <[email protected]>
1 parent 0b6179b commit 28bffa5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

libs/providers/flipt/src/lib/flipt-provider.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,27 @@ describe('FliptProvider', () => {
193193
expect(value).toHaveProperty('value', { hello: 'world' });
194194
});
195195

196+
it('should return right value for default value', async () => {
197+
fetchMock.post(
198+
variantEndpoint,
199+
{
200+
match: false,
201+
segmentKeys: [],
202+
reason: 'DEFAULT_EVALUATION_REASON',
203+
variantKey: '10',
204+
variantAttachment: `{"hello": "world"}`,
205+
requestId: '0f39483c-d52b-42b4-adbb-40b98bc7058d',
206+
requestDurationMillis: 0.409,
207+
timestamp: '2024-01-15T18:51:50.629551Z',
208+
flagKey: 'flag_json',
209+
},
210+
{ overwriteRoutes: true },
211+
);
212+
213+
const value = await provider.resolveObjectEvaluation('flag_json', {}, { fizz: 'buzz' });
214+
expect(value).toHaveProperty('value', { hello: 'world' });
215+
});
216+
196217
it('should throw TypeMismatchError on non-number value', async () => {
197218
fetchMock.post(
198219
variantEndpoint,

libs/providers/flipt/src/lib/flipt-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class FliptProvider implements Provider {
169169
};
170170
}
171171

172-
if (!variantEvaluation.match) {
172+
if (!variantEvaluation.match && variantEvaluation.reason != 'DEFAULT_EVALUATION_REASON') {
173173
return {
174174
value: defaultValue,
175175
reason: StandardResolutionReasons.DEFAULT,

0 commit comments

Comments
 (0)