nautechsystems/nautilus_trader · error · ValueError
Theme name cannot be empty
Error message
Theme name cannot be empty
What it means
register_theme refuses blank names (name.strip() falsy) after its three None checks on name/template/colors. An empty theme name could never be selected via get_theme from configs, so it is rejected at registration time.
Source
Thrown at python/nautilus_trader/analysis/themes.py:173
... "custom",
... "plotly_white",
... {
... "primary": "#ff6600",
... "positive": "#00ff00",
... "negative": "#ff0000",
... "neutral": "#808080",
... "background": "#ffffff",
... "grid": "#dddddd",
... },
... )
"""
_require_not_none(name, "name")
_require_not_none(template, "template")
_require_not_none(colors, "colors")
if not name.strip():
raise ValueError("Theme name cannot be empty")
required_keys = {"primary", "positive", "negative", "neutral", "background", "grid"}
missing_keys = required_keys - set(colors.keys())
if missing_keys:
raise ValueError(
f"Colors dict missing required keys: {missing_keys}. Required keys: {required_keys}",
)
_THEMES[name] = {
"template": template,
"colors": colors.copy(),
}
def list_themes() -> list[str]:
"""
List all registered theme names.
View on GitHub (pinned to a4b06ed870)
Solutions
- Register with a real name: register_theme('corp-brand', 'plotly_white', colors)
- Sanitize before registering: name = raw.strip(); if not name: raise/skip
Example fix
# before
register_theme('', 'plotly_white', colors)
# ValueError: Theme name cannot be empty
# after
register_theme('corp-brand', 'plotly_white', colors) Defensive patterns
Strategy: validation
Validate before calling
name = (name or '').strip()
if not name:
raise ValueError('Theme name required')
register_theme(name, template, colors) Type guard
def is_valid_theme_name(name: object) -> bool:
return isinstance(name, str) and bool(name.strip()) Prevention
- Validate names from external sources before registration
- Use a config schema requiring non-empty strings for theme keys
When it happens
Trigger: register_theme('', template, colors) or register_theme(' ', ...) — e.g. a name variable built from empty user input or a config key that was never populated.
Common situations: Theme registration loops driven by a config dict; names sourced from filenames/IDs that can be blank.
Related errors
- Colors dict missing required keys: {missing_keys}. Required
- {name} must not be None
- Theme '{name}' not found.{suggestion_text} Available themes:
- No tearsheet chart registered under '{chart_name}'.{hint} Re
- Chart renderer must be callable, was {type(renderer)}
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/dc52b7ae6870a56a.
Report an issue: GitHub.