structurizr / lite

Structurizr Lite
https://docs.structurizr.com/lite
MIT License
226 stars 26 forks source link

Workspace generation fails when documentation key is absent #62

Closed Midnighter closed 1 year ago

Midnighter commented 1 year ago

Description

I'm reporting this here, since the problem occurred for me with lite. The source may well reside in other parts of the ecosystem.

The problem is the following: I have a workspace definition (JSON) where the workspace has no documentation key. This is legal according to the OpenAPI spec which does not require any of the workspace keys. I can upload this workspace definition and download it again without problem to an on-premise instance. However, when I try to view the workspace using structurizr lite, there is an error because null has no method getSections. I can circumvent this problem by adding "documentation": {} to the workspace JSON. I understand why this happens but it seems like it shouldn't be an issue ideally.

Steps to reproduce

  1. Create a workspace definition without a documentation key.
  2. Run latest dockerized structurizr/lite to visualize the workspace.
  3. It will fail because of a missing method getSections on the null object.

Screenshot

No response

Code sample

No response

Configuration

Docker image structurizr/lite:latest

Severity

Minor

Priority

Low

Resolution

I have no budget, please fix this for free

More information

This problem is easily avoided but it still seems that either the documentation key should be required, or its absence should be handled.

simonbrowndotje commented 1 year ago

Are you using the latest version of both the on-premises installation and Lite?

Midnighter commented 1 year ago

Take the following JSON workspace definition which is valid to upload with the latest onpremises.

{
  "id" : 0,
  "name" : "Name",
  "description" : "Description",
  "properties" : {
    "structurizr.dsl" : "d29ya3NwYWNlIHsKCiAgICBtb2RlbCB7CiAgICAgICAgdXNlciA9IHBlcnNvbiAiVXNlciIKICAgICAgICBzb2Z0d2FyZVN5c3RlbSA9IHNvZnR3YXJlU3lzdGVtICJTb2Z0d2FyZSBTeXN0ZW0iCgogICAgICAgIHVzZXIgLT4gc29mdHdhcmVTeXN0ZW0gIlVzZXMiCiAgICB9CgogICAgdmlld3MgewogICAgICAgIHN5c3RlbUNvbnRleHQgc29mdHdhcmVTeXN0ZW0gIkRpYWdyYW0xIiB7CiAgICAgICAgICAgIGluY2x1ZGUgKgogICAgICAgICAgICBhdXRvTGF5b3V0CiAgICAgICAgfQogICAgfQoKfQo="
  },
  "configuration" : { },
  "model" : {
    "people" : [ {
      "id" : "1",
      "tags" : "Element,Person",
      "properties" : {
        "structurizr.dsl.identifier" : "user"
      },
      "name" : "User",
      "relationships" : [ {
        "id" : "3",
        "tags" : "Relationship",
        "sourceId" : "1",
        "destinationId" : "2",
        "description" : "Uses"
      } ],
      "location" : "Unspecified"
    } ],
    "softwareSystems" : [ {
      "id" : "2",
      "tags" : "Element,Software System",
      "properties" : {
        "structurizr.dsl.identifier" : "softwaresystem"
      },
      "name" : "Software System",
      "location" : "Unspecified",
      "documentation" : { }
    } ]
  },
  "views" : {
    "systemContextViews" : [ {
      "key" : "Diagram1",
      "order" : 1,
      "softwareSystemId" : "2",
      "automaticLayout" : {
        "implementation" : "Graphviz",
        "rankDirection" : "TopBottom",
        "rankSeparation" : 300,
        "nodeSeparation" : 300,
        "edgeSeparation" : 0,
        "vertices" : false
      },
      "enterpriseBoundaryVisible" : true,
      "elements" : [ {
        "id" : "1",
        "x" : 0,
        "y" : 0
      }, {
        "id" : "2",
        "x" : 0,
        "y" : 0
      } ],
      "relationships" : [ {
        "id" : "3"
      } ]
    } ],
    "configuration" : {
      "branding" : { },
      "styles" : { },
      "terminology" : { }
    }
  }
}

When I try to open that with the latest structurizr/lite, I get the following error:

Cannot invoke "com.structurizr.documentation.Documentation.getSections()" because the return value of "com.structurizr.Workspace.getDocumentation()" is null
Midnighter commented 1 year ago

That was fast. Thank you ☺️