{"record":{"id":"76f3dacb12f3b9a2","repo":"nextlevelbuilder/ui-ux-pro-max-skill","slug":"mode-action-must-be-dark-or-light","errorCode":null,"errorMessage":"mode action must be dark or light","messagePattern":"mode action must be dark or light","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/ui-ux-pro-max/scripts/reasoning_contract.py","lineNumber":98,"sourceCode":"        for action in actions:\n            _validate_action(action)\n        if len(actions) != len(set(actions)):\n            raise ValueError(\"{} contains duplicate actions\".format(condition))\n    return rules\n\n\ndef _validate_action(action):\n    if not isinstance(action, str) or \":\" not in action:\n        raise ValueError(\"action must use a known prefix: {}\".format(action))\n    prefix, value = action.split(\":\", 1)\n    if prefix not in ACTION_PREFIXES:\n        raise ValueError(\"unknown decision-rule action: {}\".format(action))\n    if prefix in TOKEN_ACTION_PREFIXES and not TOKEN_RE.fullmatch(value):\n        raise ValueError(\"invalid {} action value: {}\".format(prefix, value))\n    if prefix == \"pattern\" and not value.strip():\n        raise ValueError(\"pattern action must name a pattern\")\n    if prefix == \"mode\" and value not in {\"dark\", \"light\"}:\n        raise ValueError(\"mode action must be dark or light\")\n\n\ndef apply_decision_rules(rules, query):\n    \"\"\"Return deterministic mutations and an audit trail; never execute data.\"\"\"\n    normalized = str(query or \"\").casefold()\n    result = {\"activated\": [], \"style_ids\": [], \"constraints\": [],\n              \"pattern\": None, \"mode\": None}\n    for condition, actions in rules.items():\n        active = condition == \"must_have\" or any(\n            pattern.search(normalized)\n            for pattern in CONDITION_PATTERNS.get(condition, ()))\n        if not active:\n            continue\n        result[\"activated\"].append({\"condition\": condition, \"actions\": list(actions)})\n        for action in actions:\n            prefix, value = action.split(\":\", 1)\n            if prefix == \"style\" and value not in result[\"style_ids\"]:\n                result[\"style_ids\"].append(value)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/nextlevelbuilder/ui-ux-pro-max-skill/blob/a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5/src/ui-ux-pro-max/scripts/reasoning_contract.py#L80-L116","documentation":"Actions with the mode: prefix accept exactly two values: \"dark\" or \"light\" (membership test against {\"dark\", \"light\"}). Any other string — \"dark-mode\", \"Dark\", \"auto\", \"system\" — raises this ValueError, because apply_decision_rules stores the value directly as the result's mode field which downstream design-system generation switches on.","triggerScenarios":"_validate_action(\"mode:Dark\") (case-sensitive), _validate_action(\"mode:auto\"), _validate_action(\"mode:dark-mode\") — inside any condition's action array passed to parse_decision_rules.","commonSituations":"Rules written from memory with common theme-toggle vocabulary (\"auto\", \"system\"); capitalization copied from prose docs.","solutions":["Use exactly \"mode:dark\" or \"mode:light\" (lowercase).","If conditional/auto theming is desired, encode it as separate if_ conditions (e.g. if_light_mode_needed already exists in the vocabulary) rather than a mode value.","Case-normalize user input before composing rule JSON: value.lower()."],"exampleFix":"// before\n{\"if_mobile\": [\"mode:Dark\", \"mode:auto\"]}\n\n// after\n{\"if_mobile\": [\"mode:dark\"]}","handlingStrategy":"validation","validationCode":"VALID_MODES = {\"dark\", \"light\"}\nfor a in all_actions:\n    prefix, _, value = a.partition(\":\")\n    if prefix == \"mode\" and value not in VALID_MODES:\n        raise ValueError(f\"mode action must be dark or light; got {value!r}\")","typeGuard":"def is_valid_mode_value(value: str) -> bool:\n    return value in {\"dark\", \"light\"}","tryCatchPattern":null,"preventionTips":["Normalize mode input with value.strip().lower() before composing the action string.","Encode conditional theming via if_ conditions (e.g. if_light_mode_needed), never via mode values like 'auto'."],"tags":["decision-rules","enum","mode","validation"],"backgroundTag":null,"analyzedSha":"a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5","analyzedAt":"2026-08-14T18:51:02.321Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}