dosubot[bot] commented on issue #28735: URL: https://github.com/apache/superset/issues/28735#issuecomment-2134365654
<!-- Greeting --> Hey @kidusmakonnen! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let me know how I can assist you! <!-- Answer --> The error `TypeError: unsupported operand type(s) for +: 'int' and 'str'` indicates that the values for `table_cache_timeout` and `schema_cache_timeout` are being treated as strings instead of integers. This can happen if these values are not correctly set as integers in your configuration. To resolve this issue, ensure that the values for `table_cache_timeout` and `schema_cache_timeout` are set as integers. Here is how you can set these values correctly: 1. **Directly in the configuration file**: ```python # Ensure these values are set as integers table_cache_timeout = 300 # Example value in seconds schema_cache_timeout = 300 # Example value in seconds ``` 2. **Reading from environment variables**: ```python import os # Example of reading from environment variables and converting to integers table_cache_timeout = int(os.getenv('TABLE_CACHE_TIMEOUT', 300)) schema_cache_timeout = int(os.getenv('SCHEMA_CACHE_TIMEOUT', 300)) ``` Additionally, ensure that any cache-related functions handle the cache timeout values correctly. For example, in the `set_and_log_cache` function from `superset/utils/cache.py`, the `cache_timeout` parameter should be an integer: ```python def set_and_log_cache( cache_instance: Cache, cache_key: str, cache_value: dict[str, Any], cache_timeout: int | None = None, datasource_uid: str | None = None, ) -> None: if isinstance(cache_instance.cache, NullCache): return timeout = ( cache_timeout if cache_timeout is not None else app.config["CACHE_DEFAULT_TIMEOUT"] ) try: dttm = datetime.utcnow().isoformat().split(".")[0] value = {**cache_value, "dttm": dttm} cache_instance.set(cache_key, value, timeout=timeout) stats_logger.incr("set_cache_key") if datasource_uid and config["STORE_CACHE_KEYS_IN_METADATA_DB"]: ck = CacheKey( cache_key=cache_key, cache_timeout=cache_timeout, datasource_uid=datasource_uid, ) db.session.add(ck) except Exception as ex: # pylint: disable=broad-except logger.warning("Could not cache key %s", cache_key) logger.exception(ex) ``` By ensuring these values are integers and correctly handled in your cache-related functions, you should be able to avoid the `TypeError` and successfully fetch the schema list and table list in SQLLab <sup>[[1]](https://github.com/apache/superset/blob/master/superset/utils/core.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/utils/cache.py)</sup>. <!-- Dosu Comment Footer --> <details open> <summary> #### Details </summary> **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. </details> *To continue the conversation, mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org