Skip to content

Commit 84621b7

Browse files
committed
Fix variant analysis monitor failing
All fields in the variant analysis skipped repositories are optional, but this was not properly defined in the API types. This will correct the types and the functions processing the data such that they handle non-existing fields.
1 parent 2baa53a commit 84621b7

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

extensions/ql-vscode/src/remote-queries/gh-api/variant-analysis.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ export interface VariantAnalysisRepoTask {
7676
}
7777

7878
export interface VariantAnalysisSkippedRepositories {
79-
access_mismatch_repos: VariantAnalysisSkippedRepositoryGroup,
80-
not_found_repo_nwos: VariantAnalysisNotFoundRepositoryGroup,
81-
no_codeql_db_repos: VariantAnalysisSkippedRepositoryGroup,
82-
over_limit_repos: VariantAnalysisSkippedRepositoryGroup
79+
access_mismatch_repos?: VariantAnalysisSkippedRepositoryGroup,
80+
not_found_repo_nwos?: VariantAnalysisNotFoundRepositoryGroup,
81+
no_codeql_db_repos?: VariantAnalysisSkippedRepositoryGroup,
82+
over_limit_repos?: VariantAnalysisSkippedRepositoryGroup
8383
}

extensions/ql-vscode/src/remote-queries/variant-analysis-processor.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ function processSkippedRepositories(
100100
};
101101
}
102102

103-
function processRepoGroup(repoGroup: ApiVariantAnalysisSkippedRepositoryGroup): VariantAnalysisSkippedRepositoryGroup {
103+
function processRepoGroup(repoGroup: ApiVariantAnalysisSkippedRepositoryGroup | undefined): VariantAnalysisSkippedRepositoryGroup | undefined {
104+
if (!repoGroup) {
105+
return undefined;
106+
}
107+
104108
const repos = repoGroup.repositories.map(repo => {
105109
return {
106110
id: repo.id,
@@ -114,7 +118,11 @@ function processRepoGroup(repoGroup: ApiVariantAnalysisSkippedRepositoryGroup):
114118
};
115119
}
116120

117-
function processNotFoundRepoGroup(repoGroup: ApiVariantAnalysisNotFoundRepositoryGroup): VariantAnalysisSkippedRepositoryGroup {
121+
function processNotFoundRepoGroup(repoGroup: ApiVariantAnalysisNotFoundRepositoryGroup | undefined): VariantAnalysisSkippedRepositoryGroup | undefined {
122+
if (!repoGroup) {
123+
return undefined;
124+
}
125+
118126
const repo_full_names = repoGroup.repository_full_names.map(nwo => {
119127
return {
120128
fullName: nwo

extensions/ql-vscode/src/vscode-tests/cli-integration/remote-queries/variant-analysis-processor.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,52 +46,52 @@ describe('Variant Analysis processor', function() {
4646
'accessMismatchRepos': {
4747
'repositories': [
4848
{
49-
'fullName': access_mismatch_repos.repositories[0].full_name,
50-
'id': access_mismatch_repos.repositories[0].id
49+
'fullName': access_mismatch_repos?.repositories[0].full_name,
50+
'id': access_mismatch_repos?.repositories[0].id
5151
},
5252
{
53-
'fullName': access_mismatch_repos.repositories[1].full_name,
54-
'id': access_mismatch_repos.repositories[1].id
53+
'fullName': access_mismatch_repos?.repositories[1].full_name,
54+
'id': access_mismatch_repos?.repositories[1].id
5555
}
5656
],
57-
'repositoryCount': access_mismatch_repos.repository_count
57+
'repositoryCount': access_mismatch_repos?.repository_count
5858
},
5959
'noCodeqlDbRepos': {
6060
'repositories': [
6161
{
62-
'fullName': no_codeql_db_repos.repositories[0].full_name,
63-
'id': no_codeql_db_repos.repositories[0].id
62+
'fullName': no_codeql_db_repos?.repositories[0].full_name,
63+
'id': no_codeql_db_repos?.repositories[0].id
6464
},
6565
{
66-
'fullName': no_codeql_db_repos.repositories[1].full_name,
67-
'id': no_codeql_db_repos.repositories[1].id,
66+
'fullName': no_codeql_db_repos?.repositories[1].full_name,
67+
'id': no_codeql_db_repos?.repositories[1].id,
6868
}
6969
],
7070
'repositoryCount': 2
7171
},
7272
'notFoundRepos': {
7373
'repositories': [
7474
{
75-
'fullName': not_found_repo_nwos.repository_full_names[0]
75+
'fullName': not_found_repo_nwos?.repository_full_names[0]
7676
},
7777
{
78-
'fullName': not_found_repo_nwos.repository_full_names[1]
78+
'fullName': not_found_repo_nwos?.repository_full_names[1]
7979
}
8080
],
81-
'repositoryCount': not_found_repo_nwos.repository_count
81+
'repositoryCount': not_found_repo_nwos?.repository_count
8282
},
8383
'overLimitRepos': {
8484
'repositories': [
8585
{
86-
'fullName': over_limit_repos.repositories[0].full_name,
87-
'id': over_limit_repos.repositories[0].id
86+
'fullName': over_limit_repos?.repositories[0].full_name,
87+
'id': over_limit_repos?.repositories[0].id
8888
},
8989
{
90-
'fullName': over_limit_repos.repositories[1].full_name,
91-
'id': over_limit_repos.repositories[1].id
90+
'fullName': over_limit_repos?.repositories[1].full_name,
91+
'id': over_limit_repos?.repositories[1].id
9292
}
9393
],
94-
'repositoryCount': over_limit_repos.repository_count
94+
'repositoryCount': over_limit_repos?.repository_count
9595
}
9696
}
9797
});

0 commit comments

Comments
 (0)