silverbulletmd / silverbullet

The knowledge tinkerer's notebook
https://silverbullet.md
MIT License
2.55k stars 187 forks source link

Template Processing Fails Silently for Unknown Functions #815

Open simone-viozzi opened 8 months ago

simone-viozzi commented 8 months ago

I encountered an issue where template processing fails silently in the UI when using unknown functions, with errors only being visible in the browser's developer console. This behavior can be misleading, as it does not provide immediate and clear feedback on what went wrong.

Steps to Reproduce:

  1. Create a template that includes a call to an unknown function, e.g., {{dateAdd(today, 1, "days")}}.
  2. Use the template within SilverBullet.
  3. No error is shown in the SilverBullet UI or logs in docker, but an error appears in the browser's developer console.

Expected Behavior:

I would expect an error message to be shown in the SilverBullet UI or at least be logged in a more accessible manner, informing the user that the template processing failed due to the use of an unknown function.

Actual Behavior:

The template processing fails silently without any clear feedback in the UI. An error message is only visible in the browser's developer console: An exception was thrown as a result of invoking function insertSnippetTemplate error: Unknown function: dateAdd.

Additional Context:

This issue was discovered while trying to create a template for setting a due date as "due tomorrow" using an unrecognized function dateAdd. The lack of feedback made it difficult to identify the issue initially.

---
tags: template
description: "Due tomorrow"
hooks.snippet.slashCommand: dueTomorrow
---
[due: {{dateAdd(today, 1, "days")}}]
john-schmitz commented 4 months ago

Hi @zefhemel, I love the project and have been using it daily for a while. I would love to help out on a few issues;

I could give it a go on this issue. What do you think?

zefhemel commented 4 months ago

That'd be great.

john-schmitz commented 1 month ago

Hi, sorry. I had to change jobs since I committed to helping out, but now I have the time to work on this issue.