getredash/redash · error · Exception

You do not have access to query id %s.

Error message

You do not have access to query id %s.

What it means

In get_query_result(), after the query is found, Redash checks query.data_source is not None and has_access(query.data_source, user, view_only). Failure raises this Exception: the query exists but its data source was removed, or the current user lacks (view-only) access to it.

Source

Thrown at redash/query_runner/python.py:278

    def get_query_result(self, query_id):
        """Get result of an existing query.

        Parameters:
        :query_id integer: ID of existing query
        """
        user = self._get_current_user()

        try:
            query = models.Query.query.filter(
                models.Query.id == query_id,
                models.Query.org_id == user.org_id,
            ).one()
        except models.NoResultFound:
            raise Exception("Query id %s does not exist." % query_id)

        if query.data_source is None or not has_access(query.data_source, user, view_only):
            raise Exception("You do not have access to query id %s." % query_id)

        if query.latest_query_data is None:
            raise Exception("Query does not have results yet.")

        if query.latest_query_data.data is None:
            raise Exception("Query does not have results yet.")

        if query.latest_query_data.data_source is None or not has_access(
            query.latest_query_data.data_source, user, view_only
        ):
            raise Exception("You do not have access to query id %s." % query_id)

        return query.latest_query_data.data

    def dataframe_to_result(self, result, df):
        converted_result = pandas_to_result(df)

        result["rows"] = converted_result["rows"]

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Have an admin reattach/restore the query's data source
  2. Grant the user's group view access to the query's data source
  3. Use a different query backed by an accessible data source
Defensive patterns

Strategy: validation

Validate before calling

q = load_query(qid, org)
assert q.data_source is not None and has_access(q.data_source, user, view_only=True)

Try / catch

try:
    get_query_result(qid)
except Exception as e:
    if 'You do not have access to query id' in str(e):
        request_access(q.data_source); raise

Prevention

When it happens

Trigger: Calling get_query_result() on a query whose data source was deleted (data_source is None), or whose data source is restricted to groups the current user doesn't belong to.

Common situations: Query orphaned after its data source was deleted; sharing Python queries with users who can see the query but not its underlying data source.

Related errors


AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28). Data as JSON: /api/errors/52f01bd2959a66be. Report an issue: GitHub.