pistazie / cdk-dia

Automated diagrams of CDK provisioned infrastructure
MIT License
877 stars 37 forks source link

Missing instance family icons causing TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null error #35

Closed SamuraiPrinciple closed 1 year ago

SamuraiPrinciple commented 1 year ago

When trying to render a diagram containing C6I instance the following error occurs:

Failed to generate diagram - TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
node:internal/errors:484
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
    at new NodeError (node:internal/errors:393:5)
    at validateString (node:internal/validators:163:11)
    at Object.join (node:path:1172:7)
    at AwsIconSupplier.instanceIconByFamily (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-icon-supplier.js:82:46)
    at AwsIconSupplier.matchEC2InstanceIcon (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-icon-supplier.js:64:21)
    at AwsIconSupplier.matchIcon (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-icon-supplier.js:35:29)
    at AwsDiagramGenerator.generateCfnComponent (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-diagram-generator.js:154:40)
    at AwsDiagramGenerator.generateComponent (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-diagram-generator.js:78:30)
    at AwsDiagramGenerator.generateSubTree (/workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-diagram-generator.js:64:32)
    at /workspaces/aws-infrastructure/node_modules/cdk-dia/dist/src/diagram/aws/aws-diagram-generator.js:68:41 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v18.11.0

This is similar to the issue fixed by this commit - https://github.com/pistazie/cdk-dia/commit/90228a31209c4ecbb7aec78083a8c92b754252ec

I was wondering if it'd be possible to add some sensible defaulting to the icon selection logic, so that if the perfect icon cannot be found some generic one is used instead in order to for the diagram generation to succeed.

pistazie commented 1 year ago

Thanks for reporting. fixed in version 0.8.1

SamuraiPrinciple commented 1 year ago

Thanks for picking this up - much appreciated :)