structurizr / dsl

Structurizr DSL
https://docs.structurizr.com/dsl
Apache License 2.0
1.41k stars 266 forks source link

.DS_Store file causes exception during !include <directory> on Windows #364

Closed chipbite closed 10 months ago

chipbite commented 10 months ago

Description

Hi! This is from a discussion on this topic. Link to attached zip file.

Feel free to open a new issue with the relevant details (e.g. CLI version number, example workspace to reproduce the issue, etc).

Originally posted by @simonbrowndotje in https://github.com/structurizr/cli/discussions/136#discussioncomment-7395281


Steps to reproduce

Please find the excellent simplified test folder / DSL workspace structure (workspace.zip) from @okamiraner, here: https://github.com/structurizr/cli/discussions/136#discussioncomment-6527761. Here is also a direct link to workspace.zip. Unzip workspace.zip to get the folder structure, and open a shell there.

  1. Run structurizr on the workspace.dsl file, e g structurizr export -w workspace.dsl -f plantuml -o c4export

Expected: Includes are successfully parsed and included Actual: Exception thrown, see below:

PS C:\temp\structurizr\temp-tests\workspace> structurizr export -w .\workspace.dsl -f plantuml -o c4export
Exporting workspace from .\workspace.dsl
 - loading workspace from DSL
com.structurizr.dsl.StructurizrDslParserException: Input length = 1 at line 3 of C:\temp\structurizr\temp-tests\workspace\.\workspace.dsl: !include model
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:912)
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:128)
        at com.structurizr.cli.export.ExportCommand.run(ExportCommand.java:131)
        at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:81)
        at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:119)

Screenshot

FYR, the folder structure (of the attached zip file, workspace.zip) is:

.
│   workspace.dsl
│   
├───model
│   │   container.dsl
│   │   person.dsl
│   │   
│   └───softwaresystem
│       │   
│       └───spam
│           │   
│           └───model
│               │   container.dsl
│               │   
│               └───container
│                       core.dsl
│                       
└───views
        landscape.dsl

Code sample

Here is some of the code (contained in the files in workspace.zip), that show how the test/sample workspace is set up, with includes:

workspace.dsl

Here are includes, one for model and one for views folders.

workspace {
    model {
        !include model
    }

    views {
        !include views
    }
}

model/container.dsl

someSystem = softwaresystem "someSystem" {
    web = container "Web"
    mobile = container "Mobile"
}

model/person.dsl

!include softwaresystem/spam/modelb2c = person "B2C"
b2b = person "B2B"
staff = person "Staff"

Configuration

This was tested on windows (10). Tested on two shells, using windows cmd shell & powershell - w same results.

Structurizr version nrs.

2023-08-11  08:17            32 290 structurizr-cli-1.33.1.jar
2023-08-11  08:17            32 521 structurizr-client-1.26.1.jar
2023-08-11  08:17           176 737 structurizr-core-1.26.1.jar
2023-08-11  08:17           117 330 structurizr-d2-exporter-1.5.2.jar
2023-08-11  08:17           186 028 structurizr-dsl-1.32.0.jar
2023-08-11  08:17            77 601 structurizr-export-1.16.1.jar
2023-08-11  08:17            17 007 structurizr-graphviz-2.2.0.jar
2023-08-11  08:17            23 490 structurizr-import-1.5.0.jar

Severity

Minor

Priority

Medium

Resolution

I have no budget and there's no rush, please fix this for free

More information

Maybe this issue belongs in the DSL project instead. Sorry for that, if so.

simonbrowndotje commented 10 months ago

You're going to need to attach a ZIP file with that full directory structure if you'd like some assistance I'm afraid.

chipbite commented 10 months ago

Attached zip file, link

I put the link to the attached zip file on top now for easy access. Here is the link as well: https://github.com/structurizr/cli/files/12144612/workspace.zip

Also made some clarifications in the report.

simonbrowndotje commented 10 months ago

This is the error that I get from using the ZIP file at https://github.com/structurizr/cli/files/12144612/workspace.zip

./structurizr.sh export -w ./workspace.dsl -f plantuml -o c4export
Exporting workspace from ./workspace.dsl
 - loading workspace from DSL
com.structurizr.dsl.StructurizrDslParserException: Unexpected tokens (expected: enterprise, group, person, softwareSystem, deploymentEnvironment, element, ->) at line 1 of /Users/simon/Downloads/workspace/./model/softwaresystem/spam/model/container/core.dsl: container core "Core" { at line 6 of /Users/simon/Downloads/workspace/./model/container.dsl: !include softwaresystem/spam/model at line 3 of /Users/simon/Downloads/workspace/./workspace.dsl: !include model
    at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:912)
    at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:128)
    at com.structurizr.cli.export.ExportCommand.run(ExportCommand.java:131)
    at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:81)
    at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:119)

This error is caused by some files being included multiple times, which I don't believe is what you're seeing. I think you're still seeing https://github.com/structurizr/dsl/issues/308 and perhaps hidden files are treated differently between Windows and Mac (I don't have access to a Windows VM for a few days unfortunately).