Redash: Error 500 in public dashboards that contains query with parameters

Created on 31 Aug 2016  路  4Comments  路  Source: getredash/redash

Issue Summary

This issue was already mentioned on #1238

Steps to Reproduce

  1. Create a dashboard;
  2. Add a table visualization from a query which receives parameters;
  3. Create the public link by clicking on 'enable/disable share' and checking the 'allow public access' checkbox.

    Technical details:

  • Redash Version: master
  • Browser/OS: Chrome
  • How did you install Redash: docker

logs:

[2016-08-31 17:54:02,196][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."name", "t1"."slug", "t1"."settings" FROM "organizations" AS t1 WHERE ("t1"."slug" = %s) LIMIT 1', [u'default'])
[2016-08-31 17:54:02,199][PID:52][DEBUG][metrics] model=Organization query=select duration=2.87
[2016-08-31 17:54:02,201][PID:52][DEBUG][root] Current organization: <Organization: 1, Default> (slug: default)
[2016-08-31 17:54:02,203][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."org_id", "t1"."name", "t1"."email", "t1"."password_hash", "t1"."groups", "t1"."api_key" FROM "users" AS t1 WHERE (("t1"."id" = %s) AND ("t1"."org_id" = %s)) LIMIT 1', [1, 1])
[2016-08-31 17:54:02,207][PID:52][DEBUG][metrics] model=User query=select duration=4.03
[2016-08-31 17:54:02,209][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."org_id", "t1"."api_key", "t1"."active", "t1"."object_type", "t1"."object_id", "t1"."created_by_id" FROM "api_keys" AS t1 WHERE (("t1"."api_key" = %s) AND ("t1"."active" = %s)) LIMIT 1', [u'PqVhkXGSGpIi1eOhqywtA2ykxUql2t9BeLJizJjB', True])
[2016-08-31 17:54:02,212][PID:52][DEBUG][metrics] model=ApiKey query=select duration=2.84
[2016-08-31 17:54:02,215][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."org_id", "t1"."slug", "t1"."name", "t1"."user_id", "t1"."layout", "t1"."dashboard_filters_enabled", "t1"."is_archived" FROM "dashboards" AS t1 WHERE ("t1"."id" = %s) LIMIT 1', [1])
[2016-08-31 17:54:02,219][PID:52][DEBUG][metrics] model=Dashboard query=select duration=3.20
[2016-08-31 17:54:02,221][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."name", "t1"."slug", "t1"."settings" FROM "organizations" AS t1 WHERE ("t1"."slug" = %s) LIMIT 1', [u'default'])
[2016-08-31 17:54:02,224][PID:52][DEBUG][metrics] model=Organization query=select duration=2.54
[2016-08-31 17:54:02,225][PID:52][DEBUG][root] Current organization: <Organization: 1, Default> (slug: default)
[2016-08-31 17:54:02,234][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."updated_at", "t1"."created_at", "t1"."visualization_id", "t1"."text", "t1"."width", "t1"."options", "t1"."dashboard_id", "t1"."type", "t1"."query_id", "t2"."id", "t2"."updated_at", "t2"."created_at", "t2"."type", "t2"."query_id", "t2"."name", "t2"."description", "t2"."options", "t3"."id", "t3"."updated_at", "t3"."created_at", "t3"."org_id", "t3"."data_source_id", "t3"."latest_query_data_id", "t3"."name", "t3"."description", "t3"."query", "t3"."query_hash", "t3"."api_key", "t3"."user_id", "t3"."last_modified_by_id", "t3"."is_archived", "t3"."schedule", "t3"."options" FROM "widgets" AS t1 LEFT OUTER JOIN "visualizations" AS t2 ON ("t1"."visualization_id" = "t2"."id") LEFT OUTER JOIN "queries" AS t3 ON ("t2"."query_id" = "t3"."id") WHERE ("t1"."dashboard_id" = %s)', [1])
[2016-08-31 17:54:02,238][PID:52][DEBUG][metrics] model=Widget query=select duration=6.45
[2016-08-31 17:54:02,241][PID:52][DEBUG][peewee] ('SELECT "t1"."id", "t1"."org_id", "t1"."data_source_id", "t1"."query_hash", "t1"."query", "t1"."data", "t1"."runtime", "t1"."retrieved_at" FROM "query_results" AS t1 WHERE ("t1"."id" IS %s) LIMIT 1', [None])
[2016-08-31 17:54:02,244][PID:52][DEBUG][metrics] model=QueryResult query=select duration=3.39
[2016-08-31 17:54:02 +0000] [52] [ERROR] Error handling request /default/public/dashboards/PqVhkXGSGpIi1eOhqywtA2ykxUql2t9BeLJizJjB
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/contrib/fixers.py", line 152, in __call__
    return self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 271, in error_router
    return original_handler(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 271, in error_router
    return original_handler(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/opt/redash/current/redash/handlers/embed.py", line 155, in public_dashboard
    'dashboard': serializers.public_dashboard(dashboard)
  File "/opt/redash/current/redash/serializers.py", line 49, in public_dashboard
    widgets = {w.id: public_widget(w) for w in widget_list}
  File "/opt/redash/current/redash/serializers.py", line 49, in <dictcomp>
    widgets = {w.id: public_widget(w) for w in widget_list}
  File "/opt/redash/current/redash/serializers.py", line 22, in public_widget
    query_data = models.QueryResult.get_by_id(widget.visualization.query.latest_query_data_id).to_dict()
  File "/opt/redash/current/redash/models.py", line 86, in get_by_id
    return cls.get(cls.id == model_id)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4012, in get
    return sq.get()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2645, in get
    % self.sql())
QueryResultDoesNotExist: Instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."org_id", "t1"."data_source_id", "t1"."query_hash", "t1"."query", "t1"."data", "t1"."runtime", "t1"."retrieved_at" FROM "query_results" AS t1 WHERE ("t1"."id" IS %s)
PARAMS: [None]
Backend Bug help wanted

Most helpful comment

can anyone fix this please?
Parametrised shareable dashboard will be a super good to have feature. I want it badly too.

All 4 comments

can anyone fix this please?
Parametrised shareable dashboard will be a super good to have feature. I want it badly too.

We also need this ability

Same, this would be great to have. If I know how I would gladly join in and toss a PR for it but for now all I can do is state that it would be great to have.

We've started a project to redo permissions in Redash, which will also address this use case. To follow along you can watch #3284.

Was this page helpful?
0 / 5 - 0 ratings