emanote
emanote copied to clipboard
Malformed YAML files break Emanote
Describe the bug
When starting Emanote I get the error Unable to render template
in the browser:
Union mounting notebook layers; please wait ...
Ema App threw an exception
Unable to render template '/templates/error'
Once you fix the source of the error, this page will automatically refresh.
The console says [Error#System.UnionMount] Change handler exception: BadInput "NonStringKey []"
after loading/checking all my note files.
To Reproduce Steps to reproduce the behavior:
- Start Emanote via
emanote
oremanote run
. - Go to
http://127.0.0.1:8000/
- Get the error (n the browser)
Expected behavior Not getting the error.
Screenshots
Desktop (please complete the following information):
- Firefox 99.0.1 (64-bit)
- NixOS unstable (Flake install)
-
emanote --version
0.6.5.4
Additional context Haven't run Emanote for a few weeks/months. This is also a new computer where I copied my old notes folder.
Could you share a Markdown note file that triggers this?
Investigating ...
(Congrats on installing NixOS!)
I added this to the YAML frontmatter:

And that resulted in the live server showing:

This is expected behaviour as of b84c3b4161a4bd6bc56765219d4cfe4e15a1a464 ... are you sure you are in fact running 0.6.5.4?
Both emanote --version
and the run log say so
Ah, it seems that maybe I ran it in the wrong folder? I have a base directory that contains the meta files from all my notes tools and a single note directory afterwards. I ran the Emanote command in the base directory..
Ah, it seems that maybe I ran it in the wrong folder?
If you could create a repository on GitHub containing the files that trigger this particular issue that would be helpful. Because so far I cannot reproduce this bug on my system.
Sure, I'll try! But might take a bit
It seems to be related to https://github.com/anishathalye/dotbot. When I delete the /tmp/emanote-test/dotbot/lib
folder the error before [Info#ema] Ema live server running: http://127.0.0.1:8000
disappears.
Unfortunately I now I get this error.. (after [Info#ema] Ema live server running: http://127.0.0.1:8000
)
[Error#ema.ws.01] Ema: route 'R[/index.md]' encodes to 'index.html' but it is not isomporphic.
[("",["Testing Partial ISO law for R[/index.md] and ","Route's actual encoding: index.html","Decoding of that encoding: Just R[/index.html]","ERR: /= index.html","ERR: Just R[/index.md] /= Just R[/index.html]"]),(".html",["Testing Partial ISO law for R[/index.md] and .html","Route's actual encoding: index.html","Decoding of that encoding: Just R[/index.html]","ERR: .html /= index.html","ERR: Just R[/index.md] /= Just R[/index.html]"]),("index.html",["Testing Partial ISO law for R[/index.md] and index.html","Route's actual encoding: index.html","Decoding of that encoding: Just R[/index.html]","ERR: Just R[/index.md] /= Just R[/index.html]"])]
You should fix your `RouteEncoder`.
I'm trying to replicate this from a fresh new folder but I don't seem to be able to.. The dotbot
install seems to also have changed.
E: Actually makes sense: The dotbot
repository also has changed over time. So to reproduce I would have to download an old version of the lib
folder..
I can reproduce it. The lib
folder actually points to https://github.com/yaml/pyyaml/.
- Create empty folder and enter it
-
git clone https://github.com/yaml/pyyaml/
-
emanote gen .
- Boom!
Great! So the minimal repro is to apply this patch in the Emanote git repo and run bin/run
:
diff --git a/docs/index.yaml b/docs/index.yaml
index 13688aa6..e65997f5 100644
--- a/docs/index.yaml
+++ b/docs/index.yaml
@@ -5,3 +5,5 @@ page:
siteTitle: Emanote
headHtml: |
<snippet var="js.prism" />
+
+[]: foo
\ No newline at end of file
The proper fix here is to handle syntax errors in *.yaml
files and display them in the live-server (like we already do for syntax errors in *.md
files).[^more] And the meta-fix here is to fix Ema (https://github.com/srid/ema/pull/81) from breaking down when an exception is thrown in a Dynamic
handler.
https://github.com/srid/emanote/blob/2b6558fde2999ec22f645cb95322995b780f09f1/src/Emanote/Source/Patch.hs#L100-L101
For now, as a workaround, you can move these dotfiles out of the way, or put them in an actual dot directory (.foo
) as Emanote ignores them. I assume these are not critical to your notebook.
[^more]: Unlike the Markdown errors, however, these wouldn't be per-route. So we may also need a global errors page for displaying the full list of errors (equivalent to what the 'gen' command would display in the console).
Well, they are not dotfiles but instead a tool/script to link/deploy (dot)files to my system. But yes, they are not that important. Also, the tool can be installed as git submodule now, so I can delete the folder anyway.
Overall I think this is a decent workaround :+1: . That means we can close this?
Let's keep it open. I will implement the proper fix stated above when I get to it.