diagram-as-code icon indicating copy to clipboard operation
diagram-as-code copied to clipboard

Unknown resource type with children cause invalid memory access

Open ugwis opened this issue 5 months ago • 0 comments

Note: Unknown resource types with no children do not cause an error

command / error messages

WARN[0000] Type Hogehoge is not defined in the DAC definition file. It cannot be fall backed to service icon. Ignore this type. 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc8 pc=0xac5422f]

goroutine 1 [running]:
github.com/awslabs/diagram-as-code/internal/types.(*Resource).AddChild(...)
	/Users/kitayu/GitHub/diagram-as-code/internal/types/resource.go:157
github.com/awslabs/diagram-as-code/internal/ctl.associateChildren(0xc000178500?, 0xc000039ae8)
	/Users/kitayu/GitHub/diagram-as-code/internal/ctl/create.go:266 +0x26f
github.com/awslabs/diagram-as-code/internal/ctl.CreateDiagramFromDacFile({0x7ff7b6615961, 0x9}, 0xc0001284f0)
	/Users/kitayu/GitHub/diagram-as-code/internal/ctl/dacfile.go:63 +0x453
main.main.func1(0xc00021e300?, {0xc000128570?, 0x7?, 0xacadd47?})
	/Users/kitayu/GitHub/diagram-as-code/cmd/awsdac/main.go:48 +0x10a
github.com/spf13/cobra.(*Command).execute(0xc000220308, {0xc000148010, 0x1, 0x1})
	/Users/kitayu/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xc000220308)
	/Users/kitayu/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/kitayu/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
	/Users/kitayu/GitHub/diagram-as-code/cmd/awsdac/main.go:59 +0x2c5

Yaml template

Diagram:
  DefinitionFiles:
    - Type: URL
      Url: "https://raw.githubusercontent.com/awslabs/diagram-as-code/main/definitions/definition-for-aws-icons-light.yaml"
  Resources:
    Canvas:
      Type: AWS::Diagram::Canvas
      Direction: vertical
      Children:
        - Test
    Test:
      Type: Hogehoge # <--- unknown resource type here
      Children:
        - TestChild
    TestChild:
      Type: AWS::Diagram::Resource # <--- correct resource type

ugwis avatar Sep 12 '24 01:09 ugwis