Skip to content

Commit

Permalink
Add a debug log for the feature flag API response
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jan 11, 2023
1 parent 2f7b9a1 commit e8c12e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/feature-flags.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feature-flags.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
}
}

private async loadApiResponse() {
private async loadApiResponse(): Promise<GitHubFeatureFlagsApiResponse> {
// Do nothing when not running against github.com
if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
this.logger.debug(
Expand All @@ -342,7 +342,12 @@ class GitHubFeatureFlags implements FeatureEnablement {
repo: this.repositoryNwo.repo,
}
);
return response.data;
const remoteFlags = response.data;
this.logger.debug(
"Loaded the following default values for the feature flags from the Code Scanning API: " +
`${JSON.stringify(remoteFlags)}`
);
return remoteFlags;
} catch (e) {
if (util.isHTTPError(e) && e.status === 403) {
this.logger.warning(
Expand All @@ -351,6 +356,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
"This could be because the Action is running on a pull request from a fork. If not, " +
`please ensure the Action has the 'security-events: write' permission. Details: ${e}`
);
return {};
} else {
// Some features, such as `ml_powered_queries_enabled` affect the produced alerts.
// Considering these features disabled in the event of a transient error could
Expand Down

0 comments on commit e8c12e1

Please sign in to comment.