patrickchugh / terravision

Terravision creates Professional Cloud Architecture Diagrams from your Terraform code automatically. Supports AWS, Google and Azure.
Mozilla Public License 2.0
827 stars 79 forks source link

Unhandled error: <class 'AttributeError'>, 'list' object has no attribute 'startswith', <traceback object at 0x000002DA1E707780> #60

Closed Scott-Emberson closed 1 year ago

Scott-Emberson commented 1 year ago

Hi when trying to run the tool, I get the following error:

Unhandled error: <class 'AttributeError'>, 'list' object has no attribute 'startswith', <traceback object at 0x000002DA1E707780>

Debug log:

  Parsing D:/GT_ADO/VRX/Global-infra/env/main.tf
    Found 4 module stanza(s)
  Added Source Location: D:\GT_ADO\VRX\Global-infra\env\.modules\connectivity
  Added Source Location: D:\GT_ADO\VRX\Global-infra\env\.modules\applications\clear-connect-gateway
  Added Source Location: D:\GT_ADO\VRX\Global-infra\env\.modules\applications\market-data-hub
  Added Source Location: D:\GT_ADO\VRX\Global-infra\env\.modules\applications\global-admin
Traceback (most recent call last):
  File "D:\github\terravision\terravision", line 204, in <module>
    cli(
  File "C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\github\terravision\terravision", line 133, in draw
    tfdata = compile_tfdata(source, varfile, annotate)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\github\terravision\terravision", line 36, in compile_tfdata
    tfdata = fileparser.parse_tf_files(source, varfile, annotate)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\github\terravision\modules\fileparser.py", line 196, in parse_tf_files
    tfdata = iterative_read(tf_file_paths, hcl_dict, EXTRACT, tfdata)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\github\terravision\modules\fileparser.py", line 162, in iterative_read
    module_data = handle_module(
                  ^^^^^^^^^^^^^^
  File "D:\github\terravision\modules\fileparser.py", line 105, in handle_module
    if not module_source.startswith(".") and not module_source.startswith("\\"):
           ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'startswith'

Please let me know if you need any more information.

patrickchugh commented 1 year ago

I will be releasing a significant update that uses the Terraform binary - please test again with that once released.

patrickchugh commented 1 year ago

@Scott-Emberson Hello, thank you for your feedback and thanks for testing out Terravision and helping to make this a better product. I have recently completed a major revamp to the code which uses the terraform binary to download source files and generate initial relationships, before augmenting it with source code parsing as before. This is a significant departure from the previous approach and whilst slower, ensures a more accurate output and will handle all terraform in built functions now when encountered in the source. Please do a git pull and re-test again with the latest source code. If your problem is resolved, please close the the thread in github issues and mark it as completed. If not, please give as much detail as you can about the errors and include any source files if possible so I can reproduce your issue. Once again, thanks for helping and look forward to hearing from you soon.

P.

Scott-Emberson commented 1 year ago

This error is no longer an issue.