Skip to content

Commit 3c16b81

Browse files
committed
Fix error when model file does not exist
When you have just created a model file using the quick picker/input box, the data extension editor will try to read it and fail with an error message. This adds a check to ensure the model file exists and if it doesn't, it will not try to read in the file. This should always be safe since the model file picker will only allow you to select existing files.
1 parent 0ee090b commit 3c16b81

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-view.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
showAndLogExceptionWithTelemetry,
1919
} from "../helpers";
2020
import { extLogger } from "../common";
21-
import { outputFile, readFile } from "fs-extra";
21+
import { outputFile, pathExists, readFile } from "fs-extra";
2222
import { load as loadYaml } from "js-yaml";
2323
import { DatabaseItem, DatabaseManager } from "../local-databases";
2424
import { CodeQLCliServer } from "../cli";
@@ -161,6 +161,10 @@ export class DataExtensionsEditorView extends AbstractWebview<
161161

162162
protected async loadExistingModeledMethods(): Promise<void> {
163163
try {
164+
if (!(await pathExists(this.modelFilename))) {
165+
return;
166+
}
167+
164168
const yaml = await readFile(this.modelFilename, "utf8");
165169

166170
const data = loadYaml(yaml, {

0 commit comments

Comments
 (0)