structurizr / dsl

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

Error when deploymentNode identifier is the same as a softwareSystem or container identifier #153

Closed deinspanjer closed 2 years ago

deinspanjer commented 2 years ago

If you have a softwareSystem declared inside the enterprise section of the model, and you try to refer to it with a softwareSystemInstance in a deploymentNode that uses the same name, Lite will report an error stating that it isn't a softwareSystem.

If you reference a softwareSystem that is NOT in the enterprise section, it works fine.

Further, the CLI validates this schema without a problem.

See the following example. In it, the sysB deploymentNode will cause an error as is, even though the extSys deployment node works fine.

workspace "Testing issues with CLI and DSL include" {
    !identifiers hierarchical

    model {
        enterprise "An enterprise" {
            staff = person "An employee"
            sysA = softwareSystem "internal system A"
            sysB = softwareSystem "internal system B"
        }

        customer = person "A customer"

        extSys = softwareSystem "external system"

        !ref sysA {
            description "Is it broken?"
            tags "Internal"
            service = container "A service"
            staff -> this "Uses"
            -> sysB "calls"
        }

        //!include deployments.dsl
        live = deploymentEnvironment "Live deployment" {
            extCloud = deploymentNode "Some SaaS Cloud" {
                extSys = softwareSystemInstance extSys
            }
            dc = deploymentNode "Datacenter" {
                vpn = infrastructureNode "VPN Gateway"

                server1 = deploymentNode "Server 1" {
                    serviceA = containerInstance sysA.service
                }

                sysB = deploymentNode "Server 2" {
                    sysB = softwareSystemInstance sysB
                }
            }
        }

    }

}
deinspanjer commented 2 years ago

Maybe this is related to issue #142 in structurizr/dsl where changes were made related to hierarchical naming, and it isn't throwing an error in the CLI because that newer code isn't available in the published CLI packages yet?

simonbrowndotje commented 2 years ago

Adding a smaller example of this problem:

workspace {

    !identifiers hierarchical

    model {
        ss = softwareSystem "SS"

        live = deploymentEnvironment "Environment" {
            dn = deploymentNode "DN1" {
                ss = deploymentNode "DN2" {
                    softwareSystemInstance ss
                }
            }
        }

    }

}
simonbrowndotje commented 2 years ago

This can also happen for hierarchical identifier naming, where nested deployment nodes match a container identifier. Example:

workspace {

    !identifiers hierarchical

    model {
        ss = softwareSystem "SS" {
            c = container "C"
        }

        live = deploymentEnvironment "Environment" {
            dn = deploymentNode "DN1" {
                ss = deploymentNode "DN2" {
                    c = deploymentNode "DN3" {
                        containerInstance ss.c
                    }
                }
            }
        }

    }

}