getredash/redash · error · Exception
You do not have access to data source: %s.
Error message
You do not have access to data source: %s.
What it means
After resolving a data source, _get_data_source() checks has_access(data_source, user, access_level) against the current user's group permissions. Failure raises this Exception — the data source exists but the user executing the Python query isn't in a group with the required access level (view or edit).
Source
Thrown at redash/query_runner/python.py:226
if "rows" not in result:
result["rows"] = []
result["rows"].append(values)
def _get_data_source(self, data_source_name_or_id, access_level):
user = self._get_current_user()
try:
data_sources = models.DataSource.query.filter(models.DataSource.org_id == user.org_id)
if isinstance(data_source_name_or_id, int):
data_source = data_sources.filter(models.DataSource.id == data_source_name_or_id).one()
else:
data_source = data_sources.filter(models.DataSource.name == data_source_name_or_id).one()
except (models.NoResultFound, MultipleResultsFound):
raise Exception("Wrong data source name/id: %s." % data_source_name_or_id)
if not has_access(data_source, user, access_level):
raise Exception("You do not have access to data source: %s." % data_source_name_or_id)
return data_source
def execute_query(self, data_source_name_or_id, query, result_type=None):
"""Run query from specific data source.
Parameters:
:data_source_name_or_id string|integer: Name or ID of the data source
:query string: Query to run
"""
data_source = self._get_data_source(data_source_name_or_id, not_view_only)
data, error = data_source.query_runner.run_query(query, self._current_user)
if error is not None:
raise Exception(error)
# TODO: allow avoiding the JSON dumps/loads in same process
query_result = dataView on GitHub (pinned to ca79fe988d)
Solutions
- Add the user (or their group) to a data source group with sufficient permission in data source settings
- If only viewing is needed, ensure the code path requests view-only access
- Switch to a data source the user can access, or have an admin duplicate the query under proper permissions
Defensive patterns
Strategy: validation
Validate before calling
from redash.permissions import has_access ds = resolve_data_source(ref, org) assert ds is not None and has_access(ds, user, access_level), 'user lacks data source access'
Try / catch
try:
execute_query(ref, q)
except Exception as e:
if 'You do not have access to data source' in str(e):
raise UserVisibleError('Request access to data source %s' % ref) Prevention
- Grant viewer group access before sharing queries that read that source
- Test shared queries under a low-privilege user account
When it happens
Trigger: Calling execute_query() from a Python query on a data source where the current user only has view-only access but edit-level is requested, or has no group membership granting access at all.
Common situations: The Python query runs as the querying user (not the query author), so sharing a query with users lacking data source access fails; data source moved to a restricted group after the query was created.
Related errors
- You do not have access to query id %s.
- Python query helpers require a current user.
- You don't have permission to edit this resource.
- '{0}' is not configured as a supported import module
- '{} is not supported inplace variable
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/37423d8ac9388610.
Report an issue: GitHub.