getredash/redash · error · Exception
'{0}' is not configured as a supported import module
Error message
'{0}' is not configured as a supported import module What it means
The Python query runner executes user code in RestrictedPython with a whitelist of importable modules (set via the allowed import modules config). custom_import() raises this Exception when import/from-import requests a module not on that whitelist — it is a sandbox restriction, not a missing package.
Source
Thrown at redash/query_runner/python.py:156
sys.path.append(p)
if self.configuration.get("additionalBuiltins", None):
for b in self.configuration["additionalBuiltins"].split(","):
if b not in self.safe_builtins:
self.safe_builtins += (b,)
def custom_import(self, name, globals=None, locals=None, fromlist=(), level=0):
if name in self._allowed_modules:
m = None
if self._allowed_modules[name] is None:
m = importlib.import_module(name)
self._allowed_modules[name] = m
else:
m = self._allowed_modules[name]
return m
raise Exception("'{0}' is not configured as a supported import module".format(name))
@staticmethod
def custom_write(obj):
"""
Custom hooks which controls the way objects/lists/tuples/dicts behave in
RestrictedPython
"""
return full_write_guard(obj)
@staticmethod
def custom_get_item(obj, key):
return obj[key]
@staticmethod
def custom_get_iter(obj):
return iter(obj)
@staticmethodView on GitHub (pinned to ca79fe988d)
Solutions
- Add the module to the Python runner's allowed import modules setting/environment and restart workers
- Import only whitelisted modules in the query; restructure the query to use already-available libraries (pandas is typically available)
- Check exact module name spelling/case matches the whitelist entry
- Use a different data source / external script if the module genuinely can't be allow-listed for security reasons
Example fix
# before import requests # not whitelisted # after (after admin adds 'requests' to allowed import modules, or:) import pandas as pd # already allowed
Defensive patterns
Strategy: validation
Validate before calling
allowed = set(get_allowed_import_modules()) # from runner config
needed = scan_imports(query_code) # ast-based import scanner
missing = needed - allowed
assert not missing, f'ask admin to allow: {missing}' Type guard
def import_ok(module: str, allowed: set) -> bool:
top = module.split('.')[0]
return top in allowed Prevention
- Maintain a documented list of whitelisted modules for query authors
- Static-scan Python queries for imports before save/deploy
- Keep RestrictedPython and the allow-list in sync across worker upgrades
When it happens
Trigger: Running a Python query containing e.g. `import requests` when requests is not in the REDASH_ENABLED_IMPORT_MODULES / allowed modules list for the runner worker.
Common situations: Admin hasn't extended allowed modules after users request numpy/pandas/requests; module name case mismatch; or attempting to import a submodule of an allowed top-level package when only the top-level was enabled.
Related errors
- '{} is not supported inplace variable
- '{0}' is not a supported column type
- Wrong data source name/id: %s.
- You do not have access to data source: %s.
- Query id %s does not exist.
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/841e9db3e3659203.
Report an issue: GitHub.