Skip to content

Commit 0354b1c

Browse files
authored
Merge pull request #1605 from github/aeisenberg/fix-missing-success
Fix deserialization error
2 parents d32a3a0 + 90577f5 commit 0354b1c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Fix a bug where results created in older versions were thought to be unsuccessful. [#1605](https://github.com/github/vscode-codeql/pull/1605)
6+
57
## 1.7.1 - 12 October 2022
68

79
- Fix a bug where it was not possible to add a database folder if the folder name starts with `db-`. [#1565](https://github.com/github/vscode-codeql/pull/1565)

extensions/ql-vscode/src/query-serialization.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { CompletedQueryInfo, LocalQueryInfo } from './query-results';
77
import { QueryHistoryInfo } from './query-history-info';
88
import { QueryStatus } from './query-status';
99
import { QueryEvaluationInfo } from './run-queries-shared';
10+
import { QueryResultType } from './pure/legacy-messages';
1011

1112
export async function slurpQueryHistory(fsPath: string): Promise<QueryHistoryInfo[]> {
1213
try {
@@ -39,6 +40,17 @@ export async function slurpQueryHistory(fsPath: string): Promise<QueryHistoryInf
3940
Object.setPrototypeOf(q.completedQuery.query, QueryEvaluationInfo.prototype);
4041
// slurped queries do not need to be disposed
4142
q.completedQuery.dispose = () => { /**/ };
43+
44+
// Previously, there was a typo in the completedQuery type. There was a field
45+
// `sucessful` and it was renamed to `successful`. We need to handle this case.
46+
if ('sucessful' in q.completedQuery) {
47+
(q.completedQuery as any).successful = (q.completedQuery as any).sucessful;
48+
delete (q.completedQuery as any).sucessful;
49+
}
50+
51+
if (!('successful' in q.completedQuery)) {
52+
(q.completedQuery as any).successful = q.completedQuery.result?.resultType === QueryResultType.SUCCESS;
53+
}
4254
}
4355
} else if (q.t === 'remote') {
4456
// A bug was introduced that didn't set the completed flag in query history
@@ -91,7 +103,10 @@ export async function splatQueryHistory(queries: QueryHistoryInfo[], fsPath: str
91103
// remove incomplete local queries since they cannot be recreated on restart
92104
const filteredQueries = queries.filter(q => q.t === 'local' ? q.completedQuery !== undefined : true);
93105
const data = JSON.stringify({
94-
version: 2, // version 2 adds the `variant-analysis` type.
106+
// version 2:
107+
// - adds the `variant-analysis` type
108+
// - ensures a `successful` property exists on completedQuery
109+
version: 2,
95110
queries: filteredQueries
96111
}, null, 2);
97112
await fs.writeFile(fsPath, data);

0 commit comments

Comments
 (0)