[Bug] Console error generated each time a note is modified
Elaws opened this issue · comments
When MetaEdit plugin is activated, console shows the following error each time a note is modified :
Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at OnFileModifyAutomatorManager.onFileModify (eval at <anonymous> (app.js:1), <anonymous>:5266:29)
I have not encountered any problem linked to this error message, but I would like to know the cause and possibly get rid of it.
Thanks !
Also running into this issue. The warning is also only being thrown when the note has no frontmatter
This is the JS where the error is being thrown:
async onFileModify(file) {
const outfile = abstractFileToMarkdownTFile(file);
if (!outfile)
return;
// Return on Excalidraw files to prevent conflict with its auto-save feature.
const metadata = await this.app.metadataCache.getFileCache(outfile);
const keys = Object.keys(metadata === null || metadata === void 0 ? void 0 : metadata.frontmatter); // <<<< ERROR
And here's the corresponding Typescript:
MetaEdit/src/automators/onFileModifyAutomatorManager.ts
Lines 56 to 62 in a835c79
Putting a simple null check on metadata.frontmatter
should fix this.
@willdhorn Can you fix it success? I alse have the error.
When I create a new note, console like this
Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at OnFileModifyAutomatorManager.onFileModify (eval at <anonymous> (app.js:1:1433712), <anonymous>:5267:23)
Hey! I just merged #66 from @ryanjamurphy which fixes this. Thank you for your report!
@ryanjamurphy : The problem is occurring in Obsidian 1.0.3. Is this expected ?
@ryanjamurphy : The problem is occurring in Obsidian 1.0.3. Is this expected ?
I have not seen the error since the fix mentioned above was implemented, and I have been using 1.1 for a week or two.
@ryanjamurphy : I can confirm the problem is occurring on Obsidian 1.0.3, new vault with only metaedit (I just created a new note, start typing in it and the error regularly occurs) :
Maybe Obsidian 1.1 fixes this, I will check once it's released.
EDIT : And apparently, that issue is mentioned here : #72
I am still getting this exact error in version 1.1.9 on mac on every edit.
As far as anyone knows, this error occurs because one or more notes linked in the Kanban do not have frontmatter. Set up your notes properly for use with Kanban Board Helper, or, if folks insist on having frontmatter-less notes, someone can try to figure out a better check for null and submit a PR.
Continuing to report the error is fine if that's all you want to do, but it isn't helping anyone.
For context, I have not seen this error for about a year.