silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.03k stars 140 forks source link

Template Processing Fails Silently for Unknown Functions #815

Open simone-viozzi opened 3 months ago

simone-viozzi commented 3 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")}}]