Skip to content

Terravision hangs in resolve_all_variables() when source is tfdata.json (stuck in strip_var_curlies) #159

@ClementV78

Description

@ClementV78

Summary

Terravision hangs during variable resolution when using a tfdata.json source. The process spins CPU and never reaches rendering. Stack trace shows it looping in:
modules/interpreter.py -> find_replace_values -> helpers.strip_var_curlies

Environment

  • Terravision: 0.10.2 (pipx)
  • Python: 3.12.3
  • Terraform: 1.13.2
  • OS: Linux (Ubuntu/Debian based)

Repro steps

  1. Generate a tfdata.json with debug:
    terravision draw --source /path/to/terraform --debug
  2. Try to render from the JSON:
    terravision draw --source /path/to/tfdata.json --format png --outfile /tmp/out.png

Observed

  • CPU stays high, no output file produced.
  • No Graphviz processes running (dot/neato/gvpr).
  • Faulthandler trace shows loop in:
    modules/helpers.py: strip_var_curlies
    modules/interpreter.py: find_replace_values

Expected

Rendering should complete from tfdata.json without re-running variable resolution.

Workaround

Bypass Terravision CLI and call drawing.render_diagram() directly using the venv python:

  • Load tfdata.json
  • Ensure provider_detection exists
  • Call drawing.render_diagram(tfdata, False, False, outfile, format, source)
    This produces the output immediately.

Notes

The hang happens before Graphviz, during _enrich_graph_data() / resolve_all_variables().

Current thread 0x00007eafe6fc1080 (most recent call first):
  File ".../site-packages/modules/helpers.py", line 1161, in strip_var_curlies
  File ".../site-packages/modules/interpreter.py", line 483, in find_replace_values
  File ".../site-packages/modules/interpreter.py", line 165, in handle_metadata_vars
  File ".../site-packages/modules/interpreter.py", line 43, in resolve_all_variables
  File ".../site-packages/terravision/terravision.py", line 167, in _enrich_graph_data
  File ".../site-packages/terravision/terravision.py", line 249, in compile_tfdata
  File ".../site-packages/terravision/terravision.py", line 633, in draw

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions