{"record":{"id":"662559ca9bb6267c","repo":"nautechsystems/nautilus_trader","slug":"name-must-not-be-none-662559","errorCode":null,"errorMessage":"{name} must not be None","messagePattern":"(.+?) must not be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/nautilus_trader/analysis/themes.py","lineNumber":91,"sourceCode":"        \"colors\": {\n            \"primary\": \"#00cfbe\",\n            \"positive\": \"#2fadd7\",\n            \"negative\": \"#ff6b6b\",\n            \"neutral\": \"#a7aab5\",\n            \"background\": \"#2a2a2d\",\n            \"grid\": \"#202022\",\n            \"table_section\": \"#35353a\",\n            \"table_row_odd\": \"#2a2a2d\",\n            \"table_row_even\": \"#242428\",\n            \"table_text\": \"#eeeeee\",\n        },\n    },\n}\n\n\ndef _require_not_none(value: Any, name: str) -> None:\n    if value is None:\n        raise ValueError(f\"{name} must not be None\")\n\n\ndef get_theme(name: str) -> dict[str, Any]:\n    \"\"\"\n    Get theme configuration by name.\n\n    Parameters\n    ----------\n    name : str\n        The theme name. Built-in themes: \"plotly_white\", \"plotly_dark\", \"nautilus\", \"nautilus_dark\".\n\n    Returns\n    -------\n    dict[str, Any]\n        Theme configuration dictionary with \"template\" and \"colors\" keys.\n\n    Raises\n    ------","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/python/nautilus_trader/analysis/themes.py#L73-L109","documentation":"themes._require_not_none is the module's null guard, used by get_theme and register_theme to refuse None for name/template/colors arguments. It converts a would-be confusing downstream TypeError ('argument of type NoneType') into an explicit '<param> must not be None' ValueError at the API boundary.","triggerScenarios":"Calling get_theme(None) (e.g. theme name read from a config that defaulted to None), or register_theme(None, template, colors) / register_theme(name, None, colors) / register_theme(name, template, None).","commonSituations":"TearsheetConfig built programmatically where theme was never set; passing an optional config field straight through without a default; refactors that changed a required arg to None-able.","solutions":["Pass an explicit theme name, e.g. get_theme('nautilus_dark')","Default the value at the call site: theme = theme or 'plotly_white' before calling","Check required inputs when building configs from external sources (YAML/CLI)"],"exampleFix":"# before\nget_theme(cfg.get('theme'))  # cfg['theme'] missing -> None\n# ValueError: name must not be None\n\n# after\nget_theme(cfg.get('theme') or 'plotly_white')","handlingStrategy":"validation","validationCode":"if theme_name is None:\n    theme_name = 'plotly_white'\ntheme = get_theme(theme_name)","typeGuard":"def is_theme_name(value: object) -> bool:\n    return isinstance(value, str) and bool(value)","tryCatchPattern":"try:\n    theme = get_theme(name)\nexcept ValueError as e:\n    if 'must not be None' in str(e):\n        theme = get_theme('plotly_white')\n    else:\n        raise","preventionTips":["Give theme/template/colors explicit defaults at the call site instead of None","Validate config schemas so optional string fields resolve to concrete defaults"],"tags":["python","themes","null-check","argument-validation"],"backgroundTag":"none-argument-validation","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}