harry0703/MoneyPrinterTurbo · error · ValueError
\n\n##### {cfg_key} is not set #####\n\nPlease set it in the
Error message
\n\n##### {cfg_key} is not set #####\n\nPlease set it in the config.toml file: {config.config_file}\n What it means
Raised by get_api_key() in app/services/material.py when config.app.get(cfg_key) (e.g. 'pexels_api_keys' or 'pixabay_api_keys') is falsy. It is a pure configuration guard before any request: no stock-footage API key is configured, so material search/download cannot proceed. The message embeds the config.toml path for immediate action.
Source
Thrown at app/services/material.py:160
# 仅在企业代理、自签证书等明确需要的场景下,允许用户通过
# `config.toml` 显式设置 `tls_verify = false` 临时关闭。
tls_verify = config.app.get("tls_verify", True)
if isinstance(tls_verify, str):
tls_verify = tls_verify.strip().lower() not in ("0", "false", "no", "off")
if not tls_verify:
logger.warning(
"TLS certificate verification is disabled by config.app.tls_verify=false. "
"Only use this in trusted proxy environments."
)
return bool(tls_verify)
def get_api_key(cfg_key: str):
api_keys = config.app.get(cfg_key)
if not api_keys:
raise ValueError(
f"\n\n##### {cfg_key} is not set #####\n\n"
f"Please set it in the config.toml file: {config.config_file}\n"
)
# if only one key is provided, return it
if isinstance(api_keys, str):
return api_keys
global _api_key_counter
with _api_key_lock:
_api_key_counter += 1
return api_keys[_api_key_counter % len(api_keys)]
def _redact_secret(message: str, secret: str) -> str:
"""
对即将写入日志的异常文本做最小范围脱敏。
View on GitHub (pinned to 1f9f19c202)
Solutions
- Open the config.toml file shown in the message and add the missing key, e.g. pexels_api_keys = ["YOUR_KEY"] under [app]
- Get the key from the matching provider (Pexels/Pixabay developer portal) — both are free
- Support a list for round-robin: pexels_api_keys = ["key1", "key2"] rotates via _api_key_counter
- Validate config.toml parses (correct section header [app], no TOML syntax errors) after editing
Example fix
# before (config.toml) [app] # pexels_api_keys missing -> ValueError: ##### pexels_api_keys is not set ##### # after [app] pexels_api_keys = ["xxxxxxxxxxxxxxxxxxxxxxxx"] pixabay_api_keys = ["yyyyyyyyyyyyyyyyyyyyyyyy"]
Defensive patterns
Strategy: validation
Validate before calling
from app.config import config
def has_api_key(cfg_key: str) -> bool:
return bool(config.app.get(cfg_key))
assert has_api_key('pexels_api_keys') or has_api_key('pixabay_api_keys'), \
'configure at least one stock-footage key' Try / catch
except ValueError as e: if 'is not set' in str(e): non-retryable — prompt the user to edit config.toml at the path embedded in the message
Prevention
- Fill every *_api_keys entry in config.toml at setup time
- Validate config completeness at app startup, listing all missing keys at once
- Keep config.toml.example in sync when new keys are introduced
When it happens
Trigger: Calling material search/subscribe functions with neither [app].pexels_api_keys nor pixabay_api_keys (whichever cfg_key is requested) set in config.toml — empty section, key commented out, or WebUI saved empty value.
Common situations: Fresh install without completing config.toml; user only configured llm_provider and video-source keys but forgot the material stock keys; renamed/misplaced keys (key must match cfg_key exactly, e.g. plural 'pexels_api_keys'); config.toml syntax error making the section unparseable so .get returns None.
Related errors
- {llm_provider}: {field.config_suffix} is not set, please set
- uploaded file must contain a decodable audio stream
- background music file is empty or missing
- background music file exceeds the 30 MB limit
- background music file is empty
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/1b84fb1d80c8873a.
Report an issue: GitHub.