Skip to content

Commit

Permalink
fix: Include flag version for WRONG_TYPE migrations. (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Oct 2, 2023
1 parent 8e96a52 commit 837c4e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/shared/sdk-server/src/LDClientImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,15 @@ export default class LDClientImpl implements LDClient {
const contextKeys = convertedContext.valid ? convertedContext.kindsAndKeys : {};
const checkRatio = flag?.migration?.checkRatio;
const samplingRatio = flag?.samplingRatio;

if (!IsMigrationStage(detail.value)) {
const error = new Error(
`Unrecognized MigrationState for "${key}"; returning default value.`,
);
this.onError(error);
const reason = {
kind: 'ERROR',
errorKind: 'WRONG_TYPE',
errorKind: ErrorKinds.WrongType,
};
resolve({
value: defaultValue,
Expand All @@ -436,8 +437,9 @@ export default class LDClientImpl implements LDClient {
reason,
checkRatio,
undefined,
undefined,
flag?.version,
samplingRatio,
this.logger,
),
});
return;
Expand All @@ -455,6 +457,7 @@ export default class LDClientImpl implements LDClient {
detail.variationIndex === null ? undefined : detail.variationIndex,
flag?.version,
samplingRatio,
this.logger,
),
});
},
Expand Down

0 comments on commit 837c4e1

Please sign in to comment.