App crashes when a custom template has an invalid `status` value (TypeError: reading 'icon') / カスタムテンプレートの status に不正な値を入れるとアプリがクラッシュする (v6.0.0)

※English is not my first language, so the original Japanese text is included below for reference.

While trying out the custom template feature, I ran into the following issue. I’d appreciate it if you could take a look.

Environment:

  • Inkdrop Desktop v6.0.0
  • macOS

Steps to reproduce:

  1. Create a custom template with the following content:
---
_template:
  status: Active
---

TEST ERROR NOTE.
  1. Create a note from that template
  2. The UI stops rendering entirely and only the crash screen is shown
  3. The crash screen persists after [Reload app] and after restarting the app

This does not happen if status is lowercase (active).

Stack trace:

TypeError: Cannot read properties of undefined (reading 'icon')
    at file:///Applications/Inkdrop.app/Contents/Resources/app.asar/renderer/assets/app-69k5z5wT.js:47534:27
    at renderWithHooks (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:4351:21)
    at updateFunctionComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6497:15)
    at updateSimpleMemoComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6237:10)
    at updateMemoComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6178:9)
    at beginWork (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:7784:14)
    at performUnitOfWork (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11305:14)
    at workLoopSync (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11182:37)
    at renderRootSync (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11163:7)
    at performWorkOnRoot (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:10728:40)
    at performSyncWorkOnRoot (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:12086:3)
    at flushSyncWorkAcrossRoots_impl (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11956:17)
    at processRootScheduleInMicrotask (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11990:5)
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:12095:9

Entering an invalid value was my own mistake, but recovering from the crash screen was quite difficult, so it would be great if the app could handle an invalid status without crashing.
(One idea: fall back to status: none.)


Japanese

カスタムテンプレート機能を試している際に、以下の挙動が起こったため、ご確認いただけるとありがたいです。

環境:

  • Inkdrop v6.0.0
  • macOS Desktop 版

再現手順:

  1. 以下の内容でカスタムテンプレートを作る
---
_template:
  status: Active
---

TEST ERROR NOTE.
  1. そのテンプレートからノートを作成する
  2. UI が一切描画されなくなり、クラッシュ画面のみが表示される
  3. [Reload app] や再起動を行ってもクラッシュ画面が表示される

status を小文字の active にすると発生しませんでした。

スタックトレースは以下になります:

TypeError: Cannot read properties of undefined (reading 'icon')
    at file:///Applications/Inkdrop.app/Contents/Resources/app.asar/renderer/assets/app-69k5z5wT.js:47534:27
    at renderWithHooks (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:4351:21)
    at updateFunctionComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6497:15)
    at updateSimpleMemoComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6237:10)
    at updateMemoComponent (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:6178:9)
    at beginWork (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:7784:14)
    at performUnitOfWork (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11305:14)
    at workLoopSync (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11182:37)
    at renderRootSync (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11163:7)

    at performWorkOnRoot (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:10728:40)
    at performSyncWorkOnRoot (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:12086:3)
    at flushSyncWorkAcrossRoots_impl (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11956:17)
    at processRootScheduleInMicrotask (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:11990:5)
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom-client.production.js:12095:9

不正な値をいれてしまったのは自分のミスなのですが、クラッシュ画面からの復旧が大変なため、不正な値が status に指定されている場合でもクラッシュしない挙動だとありがたいです。
(思いつきではありますが、status: none になるような挙動)

@misakit さん

Thanks for the report.
Yeah, it looks like the app should validate data when creating a note to prevent from having an invalid note data that causes a crash.
So, the app would show a human-friendly error message dialog when creating a new note with an invalid data.

Btw, can you tell me how you are creating templates? Manually, or via MCP?
You might want to set a note status via UI to avoid unexpectedly specifying invalid values:

So are tags.

ご報告ありがとうございます。ご参考ください!

@craftzdog さん

Thanks for the reply.

Validating on note creation and showing an error dialog would be much appreciated.

To answer your question: I create templates manually.

And thanks for the tip about setting the status from the UI. I had a reason for not doing that, though. When I set a status on the custom template note itself, I noticed this:

  1. I set the custom template note’s status to Active.
  2. The note count next to Status > Active in the sidebar goes up by 1.
  3. When I open Status > Active, the number of notes in the list doesn’t match the count in the sidebar. Custom templates aren’t listed there.

It’s a minor thing, but it bothered me a little. So I left the template note’s own status as None and wrote status in the frontmatter instead. That way the sidebar count stays unchanged.

In any case, it really is a small thing, so I’ll set it from the UI as you suggested.

Thanks again for the quick response.

1 Like

Thanks for letting me know your workflow.

ahhh didn’t notice that! Thanks. It makes sense.

1 Like

Thank you for taking the time to look into it!

v6.1.0 should address all the issues you reported!

  1. It shows an error when creating an invalid template
  2. It no longer includes template notes in the note status counts on the sidebar

Thanks so much for your feedback :heart:

1 Like

I confirmed both are fixed on v6.1.0.

Thanks for the quick turnaround!

1 Like