Skip to content

Commit f4d5ff9

Browse files
authored
Merge pull request #93 from launchdarkly/eb/valid-flag
add check for $valid property
2 parents aa78b6e + 0ccde84 commit f4d5ff9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ export function initialize(env, user, options = {}) {
4141
// the rest of the metadata we want. We do it this way for backward compatibility with older JS SDKs.
4242
const keys = Object.keys(data);
4343
const metadataKey = '$flagsState';
44+
const validKey = '$valid';
4445
const metadata = data[metadataKey];
4546
if (!metadata && keys.length) {
4647
console.warn(messages.bootstrapOldFormat());
4748
}
49+
if (data[validKey] === false) {
50+
console.warn(messages.bootstrapInvalid());
51+
}
4852
const ret = {};
4953
keys.forEach(key => {
50-
if (key !== metadataKey) {
54+
if (key !== metadataKey && key !== validKey) {
5155
let flag = { value: data[key] };
5256
if (metadata && metadata[key]) {
5357
flag = utils.extend(flag, metadata[key]);

src/messages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export const bootstrapOldFormat = function() {
4545
);
4646
};
4747

48+
export const bootstrapInvalid = function() {
49+
return 'LaunchDarkly bootstrap data is not available because the back end could not read the flags.';
50+
};
51+
4852
export const deprecated = function(oldName, newName) {
4953
return '[LaunchDarkly] "' + oldName + '" is deprecated, please use "' + newName + '"';
5054
};

0 commit comments

Comments
 (0)