Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Disable Django CacheKeyWarning (#16559)
Marcin Wcisło64d413d87b7e
diff --git a/saleor/settings.py b/saleor/settings.pyindex 1eaeca702e..1cc71192db 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -16,6 +16,7 @@ import sentry_sdkimport sentry_sdk.utilsfrom celery.schedules import crontabfrom django.conf import global_settings+from django.core.cache import CacheKeyWarningfrom django.core.exceptions import ImproperlyConfiguredfrom django.core.management.utils import get_random_secret_keyfrom django.core.validators import URLValidator@@ -988,3 +989,8 @@ ENABLE_LIMITING_WEBHOOKS_FOR_IDENTICAL_PAYLOADS = get_bool_from_env(# Transaction items limit for PaymentGatewayInitialize / TransactionInitialize.# That setting limits the allowed number of transaction items for single entity.TRANSACTION_ITEMS_LIMIT = 100+++# Disable Django warnings regarding too long cache keys being incompatible with+# memcached to avoid leaking key values.+warnings.filterwarnings("ignore", category=CacheKeyWarning)diff --git a/saleor/tests/test_cache_key_warning.py b/saleor/tests/test_cache_key_warning.pynew file mode 100644index 0000000000..682d54f621--- /dev/null+++ b/saleor/tests/test_cache_key_warning.py@@ -0,0 +1,16 @@+import warnings++from django.core.cache import CacheKeyWarning, cache+++def test_ignore_cache_key_warning():+ key_over_250_characters = 300 * "x"++ # Ensure all warnings are errors+ warnings.simplefilter("error")++ # Ignore CacheKeyWarning+ warnings.filterwarnings("ignore", category=CacheKeyWarning)++ # Call a function that throws warning+ cache.set(key_over_250_characters, "bar")