28mm / blast-radius

Interactive visualizations of Terraform dependency graphs using d3.js
https://28mm.github.io/blast-radius-docs/
MIT License
2.04k stars 257 forks source link

No HCL object could be decoded #31

Closed davewongillies closed 6 years ago

davewongillies commented 6 years ago

When I attempt to run blast-radius against some of my larger Terraform modules, I'm getting the following:

127.0.0.1 - - [24/Apr/2018 13:46:40] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Apr/2018 13:46:42] "GET /graph.svg HTTP/1.1" 200 -
[2018-04-24 13:46:43,373] ERROR in app: Exception on /graph.json [GET]
Traceback (most recent call last):
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/blastradius/server/server.py", line 57, in graph_json
    tf = Terraform(os.getcwd())
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/blastradius/handlers/terraform.py", line 49, in __init__
    self.modules[name] = Terraform(directory=self.directory+'/'+source, settings=mod)
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/blastradius/handlers/terraform.py", line 26, in __init__
    self.config = hcl.load(config_io)
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/hcl/api.py", line 51, in load
    return loads(fp.read())
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/hcl/api.py", line 61, in loads
    if isHcl(s):
  File "my_home/.local/share/virtualenvs/blast-radius-g0pBURgw/lib/python3.5/site-packages/hcl/api.py", line 39, in isHcl
    raise ValueError("No HCL object could be decoded")
ValueError: No HCL object could be decoded

This module in particular has 243 edges:

$ terraform graph | grep -c '\->'
243

When I run blast-radius against my smaller modules, it can generate the graph.json just fine.

28mm commented 6 years ago

Hi @davewongillies -- thanks for reporting. It looks like PyHCL is raising a exception that should only result from empty/all-whitespace input. [1]

Off the top of my head I can't think of what would cause blast-radius to feed empty input, but...

What do your directory structure and blast-radius invocation look like?

[1] https://github.com/virtuald/pyhcl/blob/0830b300774f94b930255bded91c08cb03c1df8e/src/hcl/api.py#L21

davewongillies commented 6 years ago

Closing this, I think my only issue ended up being fixed by #32