structurizr / java

Structurizr for Java
https://docs.structurizr.com/java
Apache License 2.0
1.01k stars 288 forks source link

Unknown model item type on 'element' #298

Closed kristofdepypere closed 5 months ago

kristofdepypere commented 5 months ago

Description

I'm having issues using the new Inspect feature.

We are getting a stacktrace running it from cli and in the onpremise webapp we even can make the instance crash. On one of our workspaces we are getting the following error:

java.lang.reflect.InvocationTargetException: null
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(Unknown Source) ~[?:?]
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source) ~[?:?]
    at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:?]
    at com.structurizr.cli.InspectCommand.findInspector(InspectCommand.java:134) [structurizr-cli.jar:]
    at com.structurizr.cli.InspectCommand.run(InspectCommand.java:83) [structurizr-cli.jar:]
    at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:83) [structurizr-cli.jar:]
    at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:104) [structurizr-cli.jar:]

Caused by: java.lang.IllegalArgumentException: Unknown model item type.
    at com.structurizr.view.Terminology.findTerminology(Terminology.java:139) ~[structurizr-core-2.1.1.jar:2.1.1]
    at com.structurizr.inspection.model.AbstractElementInspection.terminologyFor(AbstractElementInspection.java:23) ~[structurizr-inspection-2.1.1.jar:2.1.1]
    at com.structurizr.inspection.model.ElementNotIncludedInAnyViewsInspection.inspect(ElementNotIncludedInAnyViewsInspection.java:33) ~[structurizr-inspection-2.1.1.jar:2.1.1]
    at com.structurizr.inspection.model.AbstractElementInspection.run(AbstractElementInspection.java:17) ~[structurizr-inspection-2.1.1.jar:2.1.1]
    at com.structurizr.inspection.DefaultInspector.runModelInspections(DefaultInspector.java:74) ~[structurizr-inspection-2.1.1.jar:2.1.1]
    at com.structurizr.inspection.DefaultInspector.<init>(DefaultInspector.java:19) ~[structurizr-inspection-2.1.1.jar:2.1.1]
    ... 7 more

After some trial and error I traced it back to the element keyword. validateWorkspace, validateWorkspaceDSL and rendering the workspace all works. There must be something missing in the inspect logic to handle element.

Steps to reproduce

Hit Inspect on a workspace containing element in a group

Screenshot

No response

Code sample

No response

Configuration

No response

Severity

Critical

Priority

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

More information

No response

simonbrowndotje commented 5 months ago

Example to reproduce:

workspace {
    model {
        element "A"
    }
}