getredash/redash · error · Exception
'{} is not supported inplace variable
Error message
'{} is not supported inplace variable What it means
RestrictedPython replaces augmented assignments (+=, -=, etc.) with calls to custom_inplacevar(). This Python runner hook only accepts operator strings present in its IOPERATOR_TO_STR mapping and performs the operation via exec. An unrecognized operator string (custom opcodes, unusual operators, or a mismatched RestrictedPython version whose generated op string differs) raises this Exception. Note the message itself has a stray quote: "'{} is not supported inplace variable'".
Source
Thrown at redash/query_runner/python.py:177
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)
@staticmethod
def custom_inplacevar(op, x, y):
if op not in IOPERATOR_TO_STR.values():
raise Exception("'{} is not supported inplace variable'".format(op))
glb = {"x": x, "y": y}
exec("x" + op + "y", glb)
return glb["x"]
@staticmethod
def add_result_column(result, column_name, friendly_name, column_type):
"""Helper function to add columns inside a Python script running in Redash in an easier way
Parameters:
:result dict: The result dict
:column_name string: Name of the column, which should be consisted of lowercase latin letters or underscore.
:friendly_name string: Name of the column for display
:column_type string: Type of the column. Check supported data types for details.
"""
if column_type not in SUPPORTED_COLUMN_TYPES:
raise Exception("'{0}' is not a supported column type".format(column_type))
if "columns" not in result:View on GitHub (pinned to ca79fe988d)
Solutions
- Pin RestrictedPython to the version required by your Redash release (check requirements.txt) e.g. pip install RestrictedPython==<pinned>
- If you maintain the codebase, extend IOPERATOR_TO_STR with the missing operator mapping
- As a query author, replace augmented assignment with explicit form: x = x + y instead of x += y
Example fix
# before x += 1 # after x = x + 1
Defensive patterns
Strategy: fallback
Try / catch
try:
execute_python_query(code)
except Exception as e:
if 'not supported inplace variable' in str(e):
code = rewrite_augmented_assignments(code) # x += 1 -> x = x + 1
execute_python_query(code) Prevention
- Pin RestrictedPython to the version in requirements.txt
- In shared query templates avoid augmented assignment
- Extend IOPERATOR_TO_STR if you control the runner
When it happens
Trigger: Executing a Python query with an augmented assignment whose operator token isn't in IOPERATOR_TO_STR — most commonly after upgrading RestrictedPython where the operator encoding changed, producing unknown op strings for ordinary code like x += 1.
Common situations: RestrictedPython version drift between the pinned version the runner was built for and an installed newer/older one; rarely, exotic operators (matrix @=) not in the mapping.
Related errors
- '{0}' is not configured as a supported import module
- '{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/606af334b96a8fac.
Report an issue: GitHub.