getredash/redash · error · Exception
Query id %s does not exist.
Error message
Query id %s does not exist.
What it means
get_query_result() loads a Query by id scoped to the current user's org; models.NoResultFound triggers this Exception. It means no query with that id exists in the user's organization — wrong id, deleted query, or a query belonging to a different org.
Source
Thrown at redash/query_runner/python.py:275
data_source = self._get_data_source(data_source_name_or_id, view_only)
schema = data_source.query_runner.get_schema()
return schema
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):View on GitHub (pinned to ca79fe988d)
Solutions
- Look up the correct query id from the query URL (e.g. /queries/1234) in the same instance and org
- If the query was deleted, restore it or update the Python query to use the replacement id
- Avoid hard-coding ids; store them in variables/document where they can be updated once
Example fix
# before get_query_result(123) # deleted # after get_query_result(456) # current id from /queries/456
Defensive patterns
Strategy: validation
Validate before calling
from redash import models
q = models.Query.query.filter(models.Query.id == qid, models.Query.org_id == user.org_id).first()
assert q is not None, f'query {qid} not found in this org' Try / catch
try:
get_query_result(qid)
except Exception as e:
if 'does not exist' in str(e):
qid = find_query_by_name(name); get_query_result(qid) Prevention
- Reference queries by id captured from the URL at authoring time
- Re-validate hard-coded ids after instance migrations/deletions
When it happens
Trigger: Calling get_query_result(99999) with a nonexistent id; passing an id from another Redash instance; the query was deleted; or the id exists only in a different tenant org.
Common situations: Hard-coded query ids in shared Python queries breaking after deletion; copying queries between staging and production where ids differ; typo in the literal id.
Related errors
- Wrong data source name/id: %s.
- '{0}' is not configured as a supported import module
- '{} is not supported inplace variable
- '{0}' is not a supported column type
- You do not have access to data source: %s.
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/8caa3897f8779702.
Report an issue: GitHub.