Skip to content

Commit 44ff380

Browse files
authored
Merge pull request #1295 from github/aeisenberg/result-log
Add better error messages for partial failing variant analysis
2 parents f5a5675 + 0a41713 commit 44ff380

3 files changed

Lines changed: 151 additions & 6 deletions

File tree

extensions/ql-vscode/src/helpers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ export async function showAndLogWarningMessage(message: string, {
7676
*/
7777
export async function showAndLogInformationMessage(message: string, {
7878
outputLogger = logger,
79-
items = [] as string[]
79+
items = [] as string[],
80+
fullMessage = ''
8081
} = {}): Promise<string | undefined> {
81-
return internalShowAndLog(message, items, outputLogger, Window.showInformationMessage);
82+
return internalShowAndLog(message, items, outputLogger, Window.showInformationMessage, fullMessage);
8283
}
8384

8485
type ShowMessageFn = (message: string, ...items: string[]) => Thenable<string | undefined>;

extensions/ql-vscode/src/remote-queries/run-remote-query.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ export interface QlPack {
3333
}
3434

3535
interface QueriesResponse {
36-
workflow_run_id: number
36+
workflow_run_id: number,
37+
errors?: {
38+
invalid_repositories?: string[],
39+
repositories_without_database?: string[],
40+
},
41+
repositories_queried?: string[],
3742
}
3843

3944
/**
@@ -324,14 +329,39 @@ async function runRemoteQueriesApiRequest(
324329
data
325330
}
326331
);
327-
const workflowRunId = response.data.workflow_run_id;
328-
void showAndLogInformationMessage(`Successfully scheduled runs. [Click here to see the progress](https://github.com/${owner}/${repo}/actions/runs/${workflowRunId}).`);
329-
return workflowRunId;
332+
const { popupMessage, logMessage } = parseResponse(owner, repo, response.data);
333+
void showAndLogInformationMessage(popupMessage, { fullMessage: logMessage });
334+
return response.data.workflow_run_id;
330335
} catch (error) {
331336
void showAndLogErrorMessage(getErrorMessage(error));
332337
}
333338
}
334339

340+
// exported for testng only
341+
export function parseResponse(owner: string, repo: string, response: QueriesResponse) {
342+
const popupMessage = `Successfully scheduled runs. [Click here to see the progress](https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}).`
343+
+ (response.errors ? '\n\nSome repositories could not be scheduled. See extension log for details.' : '');
344+
345+
let logMessage = `Successfully scheduled runs. See https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}.`;
346+
if (response.repositories_queried) {
347+
logMessage += `\n\nRepositories queried:\n${response.repositories_queried.join(', ')}`;
348+
}
349+
if (response.errors) {
350+
logMessage += '\n\nSome repositories could not be scheduled.';
351+
if (response.errors.invalid_repositories?.length) {
352+
logMessage += `\n\nInvalid repositories:\n${response.errors.invalid_repositories.join(', ')}`;
353+
}
354+
if (response.errors.repositories_without_database?.length) {
355+
logMessage += `\n\nRepositories without databases:\n${response.errors.repositories_without_database.join(', ')}`;
356+
}
357+
}
358+
359+
return {
360+
popupMessage,
361+
logMessage
362+
};
363+
}
364+
335365
/**
336366
* Updates the default suite of the query pack. This is used to ensure
337367
* only the specified query is run.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { expect } from 'chai';
2+
import { parseResponse } from '../../../remote-queries/run-remote-query';
3+
4+
describe('run-remote-query', () => {
5+
describe('parseResponse', () => {
6+
it('should parse a successful response', () => {
7+
const result = parseResponse('org', 'name', {
8+
workflow_run_id: 123,
9+
repositories_queried: ['a/b', 'c/d'],
10+
});
11+
12+
expect(result.popupMessage).to.equal('Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
13+
expect(result.logMessage).to.equal(
14+
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
15+
'',
16+
'Repositories queried:',
17+
'a/b, c/d'].join('\n')
18+
);
19+
});
20+
21+
it('should parse a response with no repositories queried', () => {
22+
const result = parseResponse('org', 'name', {
23+
workflow_run_id: 123,
24+
});
25+
26+
expect(result.popupMessage).to.equal('Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
27+
expect(result.logMessage).to.equal(
28+
'Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.'
29+
);
30+
});
31+
32+
it('should parse a response with invalid repos', () => {
33+
const result = parseResponse('org', 'name', {
34+
workflow_run_id: 123,
35+
repositories_queried: ['a/b', 'c/d'],
36+
errors: {
37+
invalid_repositories: ['e/f', 'g/h'],
38+
}
39+
});
40+
41+
expect(result.popupMessage).to.equal(
42+
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
43+
'',
44+
'Some repositories could not be scheduled. See extension log for details.'].join('\n')
45+
);
46+
expect(result.logMessage).to.equal(
47+
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
48+
'',
49+
'Repositories queried:',
50+
'a/b, c/d',
51+
'',
52+
'Some repositories could not be scheduled.',
53+
'',
54+
'Invalid repositories:',
55+
'e/f, g/h'].join('\n')
56+
);
57+
});
58+
59+
it('should parse a response with repos w/o databases', () => {
60+
const result = parseResponse('org', 'name', {
61+
workflow_run_id: 123,
62+
repositories_queried: ['a/b', 'c/d'],
63+
errors: {
64+
repositories_without_database: ['e/f', 'g/h'],
65+
}
66+
});
67+
68+
expect(result.popupMessage).to.equal(
69+
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
70+
'',
71+
'Some repositories could not be scheduled. See extension log for details.'].join('\n')
72+
);
73+
expect(result.logMessage).to.equal(
74+
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
75+
'',
76+
'Repositories queried:\na/b, c/d',
77+
'',
78+
'Some repositories could not be scheduled.',
79+
'',
80+
'Repositories without databases:\ne/f, g/h'].join('\n')
81+
);
82+
});
83+
84+
it('should parse a response with invalid repos and repos w/o databases', () => {
85+
const result = parseResponse('org', 'name', {
86+
workflow_run_id: 123,
87+
repositories_queried: ['a/b', 'c/d'],
88+
errors: {
89+
invalid_repositories: ['e/f', 'g/h'],
90+
repositories_without_database: ['i/j', 'k/l'],
91+
}
92+
});
93+
94+
expect(result.popupMessage).to.equal(
95+
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
96+
'',
97+
'Some repositories could not be scheduled. See extension log for details.'].join('\n')
98+
);
99+
expect(result.logMessage).to.equal(
100+
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
101+
'',
102+
'Repositories queried:\na/b, c/d',
103+
'',
104+
'Some repositories could not be scheduled.',
105+
'',
106+
'Invalid repositories:',
107+
'e/f, g/h',
108+
'',
109+
'Repositories without databases:',
110+
'i/j, k/l'].join('\n')
111+
);
112+
});
113+
});
114+
});

0 commit comments

Comments
 (0)