robswc / tradingview-webhooks-bot

a framework 🏗 for trading with tradingview webhooks!
http://tvwb.robswc.me
GNU General Public License v3.0
591 stars 180 forks source link

File "<unknown>", line 1 #27

Closed avatar-lavventura closed 1 year ago

avatar-lavventura commented 3 years ago

I keep getting following message, what may be the main cause of this error?:

SyntaxError: invalid syntax
127.0.0.1 - - [18/Jan/2021 21:08:34] "POST /webhook HTTP/1.1" 500 -
[2021-01-18 21:08:39,735] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/alper/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "webhook-bot.py", line 30, in webhook
    data = parse_webhook(request.get_data(as_text=True))
  File "/Users/alper/tools/tradingview-webhooks-bot/tradingview-webhooks-bot/actions.py", line 13, in parse_webhook
    data = ast.literal_eval(webhook_data)
  File "/usr/local/Cellar/python@3.7/3.7.9_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 46, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/usr/local/Cellar/python@3.7/3.7.9_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    ALERT!
JDJoe commented 3 years ago

line 1 ALERT!

avatar-lavventura commented 3 years ago

Main issue was: I was just sending a message "Hello World" not in a .json format or anything. There was no try/catch for data = parse_webhook(request.get_data(as_text=True)) so of the string is send as a message, it will be give the generated exception output.

Kinneh04 commented 3 years ago

Hey, im having the same problem. Any updates yet?