Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Cache the SECRET_KEY, if it is not set, RAGFlow will auto gen one, but if Redis evict keys due to lack of memory, it will cause re-generate secret key, that cause all requests 401 (#17707)

Wang Qiab703b6dedc5
diff --git a/common/settings.py b/common/settings.py
index a28d09a0eb..bf540dbc91 100644
--- a/common/settings.py
+++ b/common/settings.py
@@ -175,7 +175,8 @@ def init_secret_key():
def get_secret_key():
global SECRET_KEY
if SECRET_KEY is None:
- return _get_or_create_secret_key()
+ # Why need cache it, if REDIS evict keys due to lack of memory, new secret key will be generated, cause all requests 401
+ SECRET_KEY = _get_or_create_secret_key()
return SECRET_KEY