Skip to content

Commit 0998609

Browse files
committed
env.template fix
1 parent ae56186 commit 0998609

3 files changed

Lines changed: 17 additions & 329 deletions

File tree

.cursorrules

Lines changed: 0 additions & 326 deletions
This file was deleted.

env.template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ LLM_STRICT_MODE=false
140140
# In development, defaults are used with a warning
141141
LLM_ENCRYPTION_SALT=
142142
LLM_ENCRYPTION_PASSWORD=
143-
# Alternative: Direct encryption key (if not using salt/password)
144-
LLM_ENCRYPTION_KEY= # Used in code
143+
# Alternative: direct Fernet key (32 url-safe base64 bytes). Leave empty in dev
144+
# (salt/password KDF above). Do not put inline comments on the same line as the
145+
# value — with an empty value, python-dotenv can treat "# ..." as the value.
146+
LLM_ENCRYPTION_KEY=
145147

146148
# Ollama Configuration (for local LLM provider)
147149
OLLAMA_BASE_URL=http://localhost:11434

src/config/llm_config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,19 @@ def __init__(self, encryption_key: Optional[str] = None):
169169
encryption_key: Optional encryption key. If not provided, will use environment variable
170170
or generate a new one (not recommended for production)
171171
"""
172-
self.encryption_key = encryption_key or os.getenv("LLM_ENCRYPTION_KEY")
172+
raw_key = encryption_key or os.getenv("LLM_ENCRYPTION_KEY")
173+
if isinstance(raw_key, str):
174+
raw_key = raw_key.strip()
175+
if raw_key == "":
176+
raw_key = None
177+
elif raw_key.startswith("#"):
178+
# python-dotenv misparses `KEY= # comment` as value "# comment"
179+
logger.warning(
180+
"LLM_ENCRYPTION_KEY looks like a mis-parsed .env comment; "
181+
"ignoring. Put comments on their own line or use a valid Fernet key."
182+
)
183+
raw_key = None
184+
self.encryption_key = raw_key
173185
self._fernet = None
174186
self._initialize_encryption()
175187

0 commit comments

Comments
 (0)