{"record":{"id":"dc52b7ae6870a56a","repo":"nautechsystems/nautilus_trader","slug":"theme-name-cannot-be-empty","errorCode":null,"errorMessage":"Theme name cannot be empty","messagePattern":"Theme name cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/nautilus_trader/analysis/themes.py","lineNumber":173,"sourceCode":"    ...     \"custom\",\n    ...     \"plotly_white\",\n    ...     {\n    ...         \"primary\": \"#ff6600\",\n    ...         \"positive\": \"#00ff00\",\n    ...         \"negative\": \"#ff0000\",\n    ...         \"neutral\": \"#808080\",\n    ...         \"background\": \"#ffffff\",\n    ...         \"grid\": \"#dddddd\",\n    ...     },\n    ... )\n\n    \"\"\"\n    _require_not_none(name, \"name\")\n    _require_not_none(template, \"template\")\n    _require_not_none(colors, \"colors\")\n\n    if not name.strip():\n        raise ValueError(\"Theme name cannot be empty\")\n\n    required_keys = {\"primary\", \"positive\", \"negative\", \"neutral\", \"background\", \"grid\"}\n    missing_keys = required_keys - set(colors.keys())\n    if missing_keys:\n        raise ValueError(\n            f\"Colors dict missing required keys: {missing_keys}. Required keys: {required_keys}\",\n        )\n\n    _THEMES[name] = {\n        \"template\": template,\n        \"colors\": colors.copy(),\n    }\n\n\ndef list_themes() -> list[str]:\n    \"\"\"\n    List all registered theme names.\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/python/nautilus_trader/analysis/themes.py#L155-L191","documentation":"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.","triggerScenarios":"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.","commonSituations":"Theme registration loops driven by a config dict; names sourced from filenames/IDs that can be blank.","solutions":["Register with a real name: register_theme('corp-brand', 'plotly_white', colors)","Sanitize before registering: name = raw.strip(); if not name: raise/skip"],"exampleFix":"# before\nregister_theme('', 'plotly_white', colors)\n# ValueError: Theme name cannot be empty\n\n# after\nregister_theme('corp-brand', 'plotly_white', colors)","handlingStrategy":"validation","validationCode":"name = (name or '').strip()\nif not name:\n    raise ValueError('Theme name required')\nregister_theme(name, template, colors)","typeGuard":"def is_valid_theme_name(name: object) -> bool:\n    return isinstance(name, str) and bool(name.strip())","tryCatchPattern":null,"preventionTips":["Validate names from external sources before registration","Use a config schema requiring non-empty strings for theme keys"],"tags":["python","themes","input-validation","empty-string","register-theme"],"backgroundTag":"empty-string-validation","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}