{"record":{"id":"5d27e959c4c0f517","repo":"nautechsystems/nautilus_trader","slug":"run-config-id-is-required-when-a-backtestnode-is-p","errorCode":null,"errorMessage":"run_config_id is required when a BacktestNode is provided","messagePattern":"run_config_id is required when a BacktestNode is provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/nautilus_trader/analysis/tearsheet.py","lineNumber":516,"sourceCode":"\n\ndef _create_tearsheet_from_result(\n    result: BacktestResult,\n    node: BacktestNode | None,\n    run_config_id: str | None,\n    currency: Currency | None,\n    output_path: str | None,\n    title: str,\n    config: TearsheetConfig | None,\n    benchmark_returns: pd.Series | None,\n    benchmark_name: str,\n) -> str | None:\n    resolved_run_config_id = run_config_id or result.run_config_id\n    needs_engine = config is not None and \"bars_with_fills\" in config.chart_names\n    if needs_engine and node is None:\n        raise ValueError(\"A BacktestNode is required for the bars_with_fills chart\")\n    if node is not None and resolved_run_config_id is None:\n        raise ValueError(\"run_config_id is required when a BacktestNode is provided\")\n    if node is not None and resolved_run_config_id is not None:\n        _validate_result_node_state(node, resolved_run_config_id)\n\n    engine_view = (\n        _BacktestNodeEngineView(node, resolved_run_config_id)\n        if node is not None and resolved_run_config_id is not None\n        else None\n    )\n    returns = _result_returns_series(result)\n    run_info = _result_run_info(result)\n    account_info = _result_account_info(result, node, resolved_run_config_id, currency)\n\n    if title == \"NautilusTrader Backtest Results\":\n        run_started = _format_optional_iso8601(result.run_started)\n        title = f\"<b>NautilusTrader</b> v{NAUTILUS_VERSION} - Backtest Results\"\n        title += f\"<br><sub>Run started: {run_started}</sub>\"\n\n    return create_tearsheet_from_stats(","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/python/nautilus_trader/analysis/tearsheet.py#L498-L534","documentation":"create_tearsheet can render the 'bars_with_fills' chart directly from a BacktestNode's live engine state, which is keyed by run_config_id. When a node is supplied but no run_config_id can be resolved (neither the argument nor result.run_config_id), the library cannot look up which backtest run to inspect and raises ValueError instead of guessing.","triggerScenarios":"Calling create_tearsheet(..., node=BacktestNode(...)) without passing run_config_id, where the BacktestResult also lacks a run_config_id (e.g. a result produced by an older code path or manually constructed).","commonSituations":"Passing a node only when the config asks for bars_with_fills while forgetting run_config_id; reusing results serialized before run_config_id was added; copying example code that only sets node=.","solutions":["Pass the run_config_id argument explicitly to create_tearsheet (the id of the BacktestRunConfig added to node.configs).","Capture the run_config_id from the node before running (node.configs[0].id) and store it on/with the BacktestResult.","If no per-run engine state is needed, omit node= or drop 'bars_with_fills' from config.chart_names so the node is not required."],"exampleFix":"// before\ntearsheet = create_tearsheet(result, config=config, node=node)\n// after\ntearsheet = create_tearsheet(result, config=config, node=node, run_config_id=node.configs[0].id)","handlingStrategy":"validation","validationCode":"if node is not None and not (run_config_id or getattr(result, 'run_config_id', None)):\n    raise ValueError('Provide run_config_id when passing a BacktestNode to create_tearsheet')","typeGuard":null,"tryCatchPattern":"try:\n    path = create_tearsheet(result, config=config, node=node, run_config_id=run_config_id)\nexcept ValueError as e:\n    if 'run_config_id is required' in str(e):\n        run_config_id = node.configs[0].id\n        path = create_tearsheet(result, config=config, node=node, run_config_id=run_config_id)\n    else:\n        raise","preventionTips":["Store node.configs[0].id together with the BacktestResult immediately after running the backtest.","Only construct the node argument when bars_with_fills (or other engine charts) is in config.chart_names.","Keep run_config_id in a results metadata dict alongside the result artifact."],"tags":["python","backtesting","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}