Bug description
When SQLLAB_BACKEND_PERSISTENCE: True
(the default setting) is enabled, SQL Lab fails with error "'dict' object has no attribute 'set'" preventing any SQL Lab functionality. Setting to False
resolves the issue but loses backend persistence features.
superset_bug_report_backend_persistence.md
Screenshots/recordings
No response
Superset version
5.0.0
Python version
3.10
Node version
Not applicable
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
This error happens when the backend persistence for SQL Lab is configured with a plain Python dict instead of a cachelib backend object. Superset expects RESULTS_BACKEND (and related settings) to be set to an instantiated cachelib object (like RedisCache or MemcachedCache), not a dictionary. If a dict is used, Superset tries to call set() on it and fails, causing the "'dict' object has no attribute 'set'" error.
To fix this, make sure your config uses a cachelib backend object. For example, for Redis:
from cachelib.redis import RedisCache
RESULTS_BACKEND = RedisCache(host='localhost', port=6379, db=0)
You can find more details in the official caching configuration docs. This is not a regression or internal bug, but a common configuration pitfall. Double-check your config to ensure you're not passing a dict where a cache object is required.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: Habeeb556
Hello @krasmussen37, the above command is a correct fix to add in superset_config.py
# Persisting results from running query handling using Celery workers
from cachelib.redis import RedisCache
RESULTS_BACKEND = RedisCache(host='localhost', port=6379, key_prefix='superset_results')
Comment From: betodealmeida
Let's try to improve the error message when this happens for another user in the future.
@krasmussen37, did you have RESULTS_BACKEND = {}
in your superset_config.py
? I wonder if you added that dict, or if it's coming from somewhere else when the results backend is not set.
Comment From: krasmussen37
Looking at our git history, we did previously have RESULTS_BACKEND
set to a dict, which
would have caused exactly the error you're describing:
```python # Previous configuration (from git history): RESULTS_BACKEND = { 'cache_type': 'redis', 'cache_redis_host': REDIS_HOST, 'cache_redis_port': REDIS_PORT, 'cache_redis_db': REDIS_DB, }
We fixed this by changing to the proper cachelib object:
# Current configuration: from cachelib.redis import RedisCache RESULTS_BACKEND = RedisCache( host=REDIS_HOST, port=int(REDIS_PORT), db=int(REDIS_DB), key_prefix='superset_results_' )
So yes, we likely encountered the "'dict' object has no attribute 'set'" error during development and fixed it by switching from the dict
configuration to the proper RedisCache object.