28mm / blast-radius

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

issue rendering json #75

Open zolty opened 4 years ago

zolty commented 4 years ago

Currently getting the following version using terraform 12.18

The hardcoded 12.12 version is affected by a git bug that prevents modules from working.

I am running the following in a docker container

ARG TF_VERSION=latest
ARG PYTHON_VERSION=3.7

FROM hashicorp/terraform:$TF_VERSION AS terraform

FROM python:$PYTHON_VERSION-alpine
RUN pip install -U pip ply \
 && apk add --update --no-cache graphviz ttf-freefont

COPY --from=terraform /bin/terraform /bin/terraform
COPY ./docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod +x /bin/docker-entrypoint.sh

WORKDIR /src
COPY . .
RUN pip install -e .

WORKDIR /data

ENTRYPOINT ["/bin/docker-entrypoint.sh"]
CMD ["blast-radius", "--serve"]

Getting an error 500 in chrome and firefox visiting the site.

I did try and upgrade all the python libraries. Could you point me in a good direction? seems like the json parsing isn't right.

* Serving Flask app "blastradius.server.server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
172.17.0.1 - - [19/Jan/2020 17:35:13] "GET / HTTP/1.1" 200 -
172.17.0.1 - - [19/Jan/2020 17:35:21] "GET /graph.svg HTTP/1.1" 200 -
[2020-01-19 17:35:27,651] ERROR in app: Exception on /graph.json [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/src/blastradius/server/server.py", line 61, in graph_json
    tf = Terraform(os.getcwd())
  File "/src/blastradius/handlers/terraform.py", line 26, in __init__
    self.config = hcl.load(config_io)
  File "/usr/local/lib/python3.7/site-packages/hcl/api.py", line 54, in load
    return loads(fp.read())
  File "/usr/local/lib/python3.7/site-packages/hcl/api.py", line 66, in loads
    return HclParser().parse(s)
  File "/usr/local/lib/python3.7/site-packages/hcl/parser.py", line 326, in parse
    return self.yacc.parse(s, lexer=Lexer())
  File "/usr/local/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/local/lib/python3.7/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/usr/local/lib/python3.7/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/usr/local/lib/python3.7/site-packages/hcl/parser.py", line 318, in p_error
    raise ValueError(msg)
ValueError: Line 10, column 216: unexpected IDENTIFIER
172.17.0.1 - - [19/Jan/2020 17:35:27] "GET /graph.json HTTP/1.1" 500 -
jamengual commented 4 years ago

same error here

mfriedman1-chwy commented 4 years ago

same here

matty1979 commented 4 years ago

Same error

ThiamSoon commented 4 years ago

Any idea? I also got this error.

neil-wwt commented 4 years ago

Just piling on. Also got this error. This tool is exactly what I am looking for, so I'll poke around a little bit.

Are PRs welcome if it's an easy fix?

ThiamSoon commented 4 years ago

Just piling on. Also got this error. This tool is exactly what I am looking for, so I'll poke around a little bit.

Are PRs welcome if it's an easy fix?

Thanks @neil-wwt. I still could not figure out.

Jrc356 commented 4 years ago

I just made a PR that replaces pyhcl with python-hcl2 and found that it cleared up a bunch of my parsing errors. Could you try this fork and see if this clears it up?

Here's the fork: https://github.com/Jrc356/blast-radius just clone that guy and run a pip install . in the cloned dir then use as normal

and here's the PR: #84