diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index aab244bbf95..9ce458c1a6f 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,6 +2,8 @@ ## [UNRELEASED] +- Fix a bug where results created in older versions were thought to be unsuccessful. [#1605](https://github.com/github/vscode-codeql/pull/1605) + ## 1.7.1 - 12 October 2022 - 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) diff --git a/extensions/ql-vscode/src/query-serialization.ts b/extensions/ql-vscode/src/query-serialization.ts index 4756be0aa05..b7bbfb8d98f 100644 --- a/extensions/ql-vscode/src/query-serialization.ts +++ b/extensions/ql-vscode/src/query-serialization.ts @@ -7,6 +7,7 @@ import { CompletedQueryInfo, LocalQueryInfo } from './query-results'; import { QueryHistoryInfo } from './query-history-info'; import { QueryStatus } from './query-status'; import { QueryEvaluationInfo } from './run-queries-shared'; +import { QueryResultType } from './pure/legacy-messages'; export async function slurpQueryHistory(fsPath: string): Promise { try { @@ -39,6 +40,17 @@ export async function slurpQueryHistory(fsPath: string): Promise { /**/ }; + + // Previously, there was a typo in the completedQuery type. There was a field + // `sucessful` and it was renamed to `successful`. We need to handle this case. + if ('sucessful' in q.completedQuery) { + (q.completedQuery as any).successful = (q.completedQuery as any).sucessful; + delete (q.completedQuery as any).sucessful; + } + + if (!('successful' in q.completedQuery)) { + (q.completedQuery as any).successful = q.completedQuery.result?.resultType === QueryResultType.SUCCESS; + } } } else if (q.t === 'remote') { // 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 // remove incomplete local queries since they cannot be recreated on restart const filteredQueries = queries.filter(q => q.t === 'local' ? q.completedQuery !== undefined : true); const data = JSON.stringify({ - version: 2, // version 2 adds the `variant-analysis` type. + // version 2: + // - adds the `variant-analysis` type + // - ensures a `successful` property exists on completedQuery + version: 2, queries: filteredQueries }, null, 2); await fs.writeFile(fsPath, data);