Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing docs fails on files without extension #251

Closed
KlfJoat opened this issue Feb 17, 2024 · 3 comments
Closed

Importing docs fails on files without extension #251

KlfJoat opened this issue Feb 17, 2024 · 3 comments

Comments

@KlfJoat
Copy link

KlfJoat commented Feb 17, 2024

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

  1. Create a workspace.dsl file with the contents of the canonical example file at https://docs.structurizr.com/dsl/example
  2. Add a !docs . line as shown below.
  3. Have .md files in the same directory as the workspace.dsl file.
  4. Run java -Djdk.util.jar.enableMultiRelease=false -jar structurizr-lite.war /home/klfjoat/src/project-name/docs
  5. Open URL
  6. 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

@KlfJoat
Copy link
Author

KlfJoat commented Feb 18, 2024

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).

@simonbrowndotje simonbrowndotje changed the title !docs . line causes java.lang.StringIndexOutOfBoundsException Importing docs fails on files without extension Feb 18, 2024
@simonbrowndotje simonbrowndotje transferred this issue from structurizr/lite Feb 18, 2024
@KlfJoat
Copy link
Author

KlfJoat commented Feb 19, 2024

Will you break the utter silence to share when the fix might make it to structurizr-lite?

@simonbrowndotje
Copy link
Contributor

I have no immediate plans for a release, but hopefully it will be later this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants