avisi-cloud / structurizr-site-generatr

Static site generator for architecture models created with Structurizr DSL
https://avisi-cloud.github.io/structurizr-site-generatr/
Apache License 2.0
230 stars 36 forks source link

Question/Bug: YAML frontmatter in markdown causes filenotfound exception #646

Open chipbite opened 14 hours ago

chipbite commented 14 hours ago

Hi! Just saw this, as I was trying to add some yaml frontmatter to a markdown file, when generatr rebuilds the site, I then get a filenotfound exception.

Repro

  1. I have a site with a few markdown pages in docs, that are rendered in the tree, topmost part. Works fine.
  2. I edit one of the markdown pages and add some YAML frontmatter content before the first heading. I just copied some from an adr.

So, from working start of md file, e g:

# DEXF Systems

I add like so:

---
status: "proposed"
date: "2024-11-26"
decision-makers: ""
---
# DEXF Systems
  1. generatr rebuilds and throws java.io.FileNotFoundException: build\serve\master\status:-"proposed"-date:-"2024-11-26"-decision-makers:-""\index.html (The filename, directory name, or volume label syntax is incorrect)

Trace:

Generating site...
java.io.FileNotFoundException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:564)
        at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:591)
        at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:689)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles(SiteGenerator.kt:201)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateSite(SiteGenerator.kt:89)
        at nl.avisi.structurizr.site.generatr.ServeCommand.updateSite(ServeCommand.kt:83)
        at nl.avisi.structurizr.site.generatr.ServeCommand.monitorFileChanges(ServeCommand.kt:176)
        at nl.avisi.structurizr.site.generatr.ServeCommand.startWatchService$lambda$12(ServeCommand.kt:148)
        at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.io.FileNotFoundException: build\serve\master\status:-"proposed"-date:-"2024-11-26"-decision-makers:-""\index.html (The filename, directory name, or volume label syntax is incorrect)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:235)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:184)
        at kotlin.io.FilesKt__FileReadWriteKt.writeText(FileReadWrite.kt:141)
        at kotlin.io.FilesKt__FileReadWriteKt.writeText$default(FileReadWrite.kt:140)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.writeHtmlFile(SiteGenerator.kt:238)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$52$lambda$17$lambda$16(SiteGenerator.kt:136)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$53(SiteGenerator.kt:201)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$54(SiteGenerator.kt:201)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

I hope this one is not windows only, but lets see if you can repro.

BR! /marcus

jenspav commented 14 hours ago

From a quick glimpse, it is the : that spoils this. Does it works if you leave the : out? As far as I remember, this is unfortunately a Windows only issue, at least on Linux having a : in a filename should work ;). Nevertheless we should prevent this.

chipbite commented 13 hours ago

From a quick glimpse, it is the : that spoils this.

Hmm, ok... not sure I follow - how does the content of the markdown file end up affecting the filename? Or what am I missing... 🙂

Does it works if you leave the : out?

The colon needs to be in the yaml content, AFAIK. Otherwise, its not yaml content, I guess.

flexmark can handle it, which is why I wanted to try it out. but, not the most important usecase currently.


yaml frontmatter: github, jekyll