From e270a37bfa7707e2ba44b88c502f78e2d2189458 Mon Sep 17 00:00:00 2001 From: Evolutioned <149912041+evolutioned@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:36:53 +1000 Subject: [PATCH] Protect null tags on frontmatter In my vault I get an uncaught exception from this line of code, where the tags is null. --- src/Scripting/TasksFile.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Scripting/TasksFile.ts b/src/Scripting/TasksFile.ts index 6426ac91a4..e48a818925 100644 --- a/src/Scripting/TasksFile.ts +++ b/src/Scripting/TasksFile.ts @@ -19,7 +19,10 @@ export class TasksFile { const rawFrontmatter = cachedMetadata.frontmatter; if (rawFrontmatter !== undefined) { this._frontmatter = JSON.parse(JSON.stringify(rawFrontmatter)); - this._frontmatter.tags = parseFrontMatterTags(rawFrontmatter) ?? []; + // protect against null tags (happens in my vault) + if (this._frontmatter) { + this._frontmatter.tags = parseFrontMatterTags(rawFrontmatter) ?? []; + } } if (Object.keys(cachedMetadata).length !== 0) {