nautechsystems/nautilus_trader · error · ValueError
Chart name cannot be empty
Error message
Chart name cannot be empty
What it means
A password and/or app key was supplied but no username, so BetfairCredential::resolve rejects the incomplete triple before any login attempt. As with other partial states, providing any field in config disables the environment fallback, which commonly triggers this when the username lives only in the environment but the password is set in config.
Source
Thrown at python/nautilus_trader/analysis/tearsheet.py:282
If name is empty or func is not callable.
Examples
--------
>>> # As a decorator
>>> @register_chart("my_custom_chart")
... def create_custom_chart(returns: pd.Series, **kwargs) -> go.Figure:
... fig = go.Figure()
... # ... custom visualization logic
... return fig
>>>
>>> # Or called directly
>>> register_chart("another_chart", create_custom_chart)
"""
_require_not_none(name, "name")
if not name.strip():
raise ValueError("Chart name cannot be empty")
if func is None:
def decorator(f: Callable) -> Callable:
if not callable(f):
raise ValueError(f"Chart function must be callable, was {type(f)}")
_CHART_REGISTRY[name] = f
return f
return decorator
if not callable(func):
raise ValueError(f"Chart function must be callable, was {type(func)}")
_CHART_REGISTRY[name] = func
return None
View on GitHub (pinned to a4b06ed870)
Solutions
- Set the username (config field or BETFAIR_USERNAME)
- Keep all three credentials in one place - all config or all environment
- Run a preflight completeness check that lists exactly which of the three are missing
Example fix
// before
.password("secret".into())
.app_key("xxxxxxx".into()) // username assumed from env (never read)
// after
.username("better".into())
.password("secret".into())
.app_key("xxxxxxx".into()) Defensive patterns
Strategy: validation
Validate before calling
anyhow::ensure!(
username.is_some() || (password.is_none() && app_key.is_none()),
"password/app_key provided but username is missing"
); Type guard
fn no_credentials_without_username(username: Option<&str>, password: Option<&str>, app_key: Option<&str>) -> bool {
username.is_some() || (password.is_none() && app_key.is_none())
} Prevention
- Provide username first when configuring credentials incrementally
- Keep the triple in a single secret store entry
- Add a config schema check that the three fields are all-or-none
When it happens
Trigger: Config sets password and/or app_key with no username; or the environment has BETFAIR_PASSWORD/BETFAIR_APP_KEY but BETFAIR_USERNAME is unset or typo'd; username key dropped during config migration.
Common situations: Credentials sourced half from a vault and half from env; YAML key renamed from user to username; variable dropped when moving between deployment environments.
Related errors
- {name} must not be None
- height must be positive, was {self.height}
- pandas is required for report generation; install it with `p
- pandas is required for visualization; install it with `pip i
- Chart function must be callable, was {type(f)}
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/f10d0da3feb6db31.
Report an issue: GitHub.