[GH-ISSUE #60] Unhandled error: <class 'AttributeError'>, 'list' object has no attribute 'startswith', <traceback object at 0x000002DA1E707780> #26

Closed
opened 2026-05-06 12:36:21 +02:00 by BreizhHardware · 3 comments

Originally created by @Scott-Emberson on GitHub (Sep 23, 2023).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/60

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.

Originally created by @Scott-Emberson on GitHub (Sep 23, 2023). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/60 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.
Author
Owner

@patrickchugh commented on GitHub (Oct 3, 2023):

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

<!-- gh-comment-id:1744723262 --> @patrickchugh commented on GitHub (Oct 3, 2023): I will be releasing a significant update that uses the Terraform binary - please test again with that once released.
Author
Owner

@patrickchugh commented on GitHub (Nov 21, 2023):

@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.

<!-- gh-comment-id:1820022384 --> @patrickchugh commented on GitHub (Nov 21, 2023): @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.
Author
Owner

@Scott-Emberson commented on GitHub (Nov 21, 2023):

This error is no longer an issue.

<!-- gh-comment-id:1820465935 --> @Scott-Emberson commented on GitHub (Nov 21, 2023): This error is no longer an issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terravision#26
No description provided.