diff --git a/CHANGELOG.md b/CHANGELOG.md index af60944863..e626483643 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [UNRELEASED] -- Add better error message is the workflow does not have the `security-events: write` permission. [#882](https://github.com/github/codeql-action/pull/882) +- Add a better warning message stating that experimental features will be disabled if the workflow has been triggered by a pull request from a fork or the `security-events: write` permission is not present. [#882](https://github.com/github/codeql-action/pull/882) ## 1.0.30 - 24 Jan 2022 diff --git a/lib/feature-flags.test.js b/lib/feature-flags.test.js index b459d68e2c..6f46e2db78 100644 --- a/lib/feature-flags.test.js +++ b/lib/feature-flags.test.js @@ -60,6 +60,16 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) { } }); }); +(0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => { + await (0, util_1.withTmpDir)(async (tmpDir) => { + (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); + const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true)); + (0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {}); + await t.throwsAsync(async () => featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled), { + message: "Encountered an error while trying to load feature flags: Error: some error message", + }); + }); +}); const FEATURE_FLAGS = [ "database_uploads_enabled", "ml_powered_queries_enabled", diff --git a/lib/feature-flags.test.js.map b/lib/feature-flags.test.js.map index 85b3b25c7a..532d5998d2 100644 --- a/lib/feature-flags.test.js.map +++ b/lib/feature-flags.test.js.map @@ -1 +1 @@ -{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,a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AK,MAAM,WAAW,IAAI,aAAa,EAAE;IACvC,IAAA,aAAI,EAAC,iBAAiB,WAAW,6CAA6C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;YAEF,MAAM,oBAAoB,GAAG,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;gBAC7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;aACjC;YACD,oBAAoB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAG;gBACzB,wBAAwB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACnD,2BAAW,CAAC,sBAAsB,CACnC;gBACD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,sBAAsB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"} \ No newline at end of file +{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,I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GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAG;gBACzB,wBAAwB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACnD,2BAAW,CAAC,sBAAsB,CACnC;gBACD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,sBAAsB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"} \ No newline at end of file diff --git a/src/feature-flags.test.ts b/src/feature-flags.test.ts index cba2bd797e..f8e73ec23d 100644 --- a/src/feature-flags.test.ts +++ b/src/feature-flags.test.ts @@ -102,6 +102,29 @@ test("Feature flags are disabled if they're not returned in API response", async }); }); +test("Feature flags exception is propagated if the API request errors", async (t) => { + await withTmpDir(async (tmpDir) => { + setupActionsVars(tmpDir, tmpDir); + + const featureFlags = new GitHubFeatureFlags( + { type: GitHubVariant.DOTCOM }, + testApiDetails, + testRepositoryNwo, + getRunnerLogger(true) + ); + + mockFeatureFlagApiEndpoint(500, {}); + + await t.throwsAsync( + async () => featureFlags.getValue(FeatureFlag.DatabaseUploadsEnabled), + { + message: + "Encountered an error while trying to load feature flags: Error: some error message", + } + ); + }); +}); + const FEATURE_FLAGS = [ "database_uploads_enabled", "ml_powered_queries_enabled",