Importing docs fails on files without extension
KlfJoat opened this issue · comments
Description
(I'm sorry, but your bug format isn't fitting into my brain right now, so I'm going to provide most of the info in my own format)
Observed Behavior
When running the latest structurizr-lite.war
on my workspace, I get an error in the web interface:
workspace.dsl: Error importing documentation from /home/klfjoat/src/project-name/docs/.: java.lang.StringIndexOutOfBoundsException: begin -1, end 6, length 6 at line 3 of /home/klfjoat/src/project-name/docs/workspace.dsl: !docs .
I see this error in the command line output
2024-02-17T13:28:43.662-06:00 ERROR 590777 --- [nio-8080-exec-1] s.l.c.w.FileSystemWorkspaceComponentImpl : com.structurizr.dsl.StructurizrDslParserException: Error importing documentation from /home/klfjoat/src/project-name/docs/.: java.lang.StringIndexOutOfBoundsException: begin -1, end 6, length 6 at line 3 of /home/klfjoat/src/project-name/docs/workspace.dsl: !docs .
I have not changed my workspace.dsl
file in about 5 months and it used to work.
I have plenty of .md
files in the same directory as workspace.dsl
and in the past structurizr-lite
has gleefully taken those files and displayed them for me.
Expected Behavior
Recognize that .
means 'the current directory' and pull .md
files from the same directory as the workspace.dsl
file.
Troubleshooting Steps
I have reduced the workspace.dsl
file to the bare minimum, as you can see below, and it still throws the error. This error prevents anything from showing in the web interface, even the diagrams, ADRs, and documentation (ofc).
I have tried combinations of changing the path provided to structurizr-lite.war
, the path of the !docs
line, etc. With and without trailing slashes, with named subdirs, everything I can think of.
Steps to reproduce
- Create a
workspace.dsl
file with the contents of the canonical example file at https://docs.structurizr.com/dsl/example - Add a
!docs .
line as shown below. - Have
.md
files in the same directory as theworkspace.dsl
file. - Run
java -Djdk.util.jar.enableMultiRelease=false -jar structurizr-lite.war /home/klfjoat/src/project-name/docs
- Open URL
- See error message in command-line and web UI.
Screenshot
No response
Code sample
workspace {
!docs .
model {
user = person "User"
softwareSystem = softwareSystem "Software System"
user -> softwareSystem "Uses"
}
views {
systemContext softwareSystem {
include *
autolayout lr
}
}
}
Configuration
Build 2024.01.02
Severity
Critical
Priority
I have no budget and there's no rush, please fix this for free
More information
No response
After painstakingly copying individual files from my live documentation to a clean repo, I have identified the bug. I have a repo I can post proving the issue.
For one, structurizr-lite
seems to be parsing non-Markdown and non-AsciiDoc files.
I have a header file for another documentation generator. The file is named md-header
(though my experiments prove the basename is irrelevant). Its contents can be simplified to...
<!-- Header template file I have laying around -->
When this file with no extension is present in my docs/
directory, structurizr-lite
throws the error. As I understand FormatFinder.java and DefaultDocumentationImporter.java, files without extensions should not be parsed, but they are for me.
For completeness, the output of java --version
for me is...
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-123.10)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-123.10, mixed mode, sharing)
This may also be a second bug, possibly related to structurizr/lite#44, which is that when structurizr-lite
parses a file that has no MD/ADOC content, an inscrutable error message is provided. IMO it's definitely a usability bug. This troubleshooting would have been a lot easier if the parser could tell users which file tripped it up, and preferably why (no content).
Will you break the utter silence to share when the fix might make it to structurizr-lite
?
I have no immediate plans for a release, but hopefully it will be later this month.