nautechsystems/nautilus_trader · error · ValueError
A BacktestNode is required for the bars_with_fills chart
Error message
A BacktestNode is required for the bars_with_fills chart
What it means
Thrown when the proxy entry's `target_code_hash` fails `B256::from_str`, i.e. it is not a valid 32-byte hex string. This hash pins the expected runtime bytecode of the implementation contract behind the proxy.
Solutions
- Set `target_code_hash` to the full 0x + 64-hex-char keccak256 hash of the implementation contract's deployed runtime bytecode.
- Compute the hash from eth_getCode(target_address) if the compiled artifact is unavailable.
- Ensure the hash corresponds to the same implementation version that target_address points to.
Example fix
// before (manifest.json) "target_code_hash": "0xabc123" // after (manifest.json) "target_code_hash": "0x7c2e487a1f3d..." // 64 hex chars, keccak256 of implementation runtime code
Defensive patterns
Strategy: validation
Validate before calling
fn valid_b256(s: &str) -> bool { use alloy_primitives::B256; s.len() == 66 && B256::from_str(s).is_ok() } // apply to proxy.target_code_hash Type guard
fn parse_target_hash(s: &str) -> Option<B256> { use alloy_primitives::B256; B256::from_str(s).ok() } Try / catch
let target_hash = B256::from_str(&proxy.target_code_hash).map_err(|_| anyhow!("invalid target_code_hash for {}", proxy.target_address))?; Prevention
- Hash the implementation's deployed runtime code (eth_getCode), not creation bytecode
- Copy the hash programmatically from build artifacts
- Recompute the hash whenever the implementation is redeployed
When it happens
Trigger: Manifest validation (verification.rs:1298) parses a proxy whose `target_code_hash` is malformed — wrong length, non-hex characters, empty string, or a value of a different hash type/length.
Common situations: Copying the proxy's own code hash instead of the implementation's; pasting a truncated keccak256 output; leaving the field empty in a template proxy entry; using a hash computed from creation bytecode rather than deployed runtime code.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Chart function must be callable, was
- Chart ' ' not found. Available charts: . Register custom…
- plotly is required for visualization. Install it with: pip…
- Chart function must be callable, was
- Manifest probe call data is invalid
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1541b075a3d50c51.
Report an issue: GitHub.
Appendix: source
Thrown at python/nautilus_trader/analysis/tearsheet.py:514
def generate_fills_report(self) -> pd.DataFrame:
return self._node.generate_fills_report(self._run_config_id)
def _create_tearsheet_from_result(
result: BacktestResult,
node: BacktestNode | None,
run_config_id: str | None,
currency: Currency | None,
output_path: str | None,
title: str,
config: TearsheetConfig | None,
benchmark_returns: pd.Series | None,
benchmark_name: str,
) -> str | None:
resolved_run_config_id = run_config_id or result.run_config_id
needs_engine = config is not None and "bars_with_fills" in config.chart_names
if needs_engine and node is None:
raise ValueError("A BacktestNode is required for the bars_with_fills chart")
if node is not None and resolved_run_config_id is None:
raise ValueError("run_config_id is required when a BacktestNode is provided")
if node is not None and resolved_run_config_id is not None:
_validate_result_node_state(node, resolved_run_config_id)
engine_view = (
_BacktestNodeEngineView(node, resolved_run_config_id)
if node is not None and resolved_run_config_id is not None
else None
)
returns = _result_returns_series(result)
run_info = _result_run_info(result)
account_info = _result_account_info(result, node, resolved_run_config_id, currency)
if title == "NautilusTrader Backtest Results":
run_started = _format_optional_iso8601(result.run_started)
title = f"<b>NautilusTrader</b> v{NAUTILUS_VERSION} - Backtest Results"
title += f"<br><sub>Run started: {run_started}</sub>"View on GitHub (pinned to 18893faf8b)