{"record":{"id":"20f61bbb3117cce0","repo":"nextlevelbuilder/ui-ux-pro-max-skill","slug":"pattern-action-must-name-a-pattern","errorCode":null,"errorMessage":"pattern action must name a pattern","messagePattern":"pattern action must name a pattern","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/ui-ux-pro-max/scripts/reasoning_contract.py","lineNumber":96,"sourceCode":"        if not isinstance(actions, list) or not actions:\n            raise ValueError(\"{} must map to a non-empty action array\".format(condition))\n        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)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/nextlevelbuilder/ui-ux-pro-max-skill/blob/a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5/src/ui-ux-pro-max/scripts/reasoning_contract.py#L78-L114","documentation":"Actions with the pattern: prefix must carry a non-empty, non-whitespace-only value (checked via value.strip()). A bare \"pattern:\" or \"pattern:   \" passes the ':' split and prefix check but names no layout pattern, so the rule could never resolve to a pattern at apply time — hence rejected up front.","triggerScenarios":"_validate_action(\"pattern:\"), _validate_action(\"pattern:  \") — i.e. a decision-rule JSON containing a pattern action whose value was never filled in or was lost in editing.","commonSituations":"Template rule blocks where the pattern name is a placeholder; truncation of a CSV cell mid-action; deleting the value but leaving the prefix while refactoring rules.","solutions":["Fill in a concrete pattern name, e.g. \"pattern:hero-split\" or \"pattern:card-grid\".","If no pattern is intended, delete the whole pattern: action from the array (arrays just must stay non-empty overall).","Lint payloads with parse_decision_rules before committing so empty placeholders fail fast."],"exampleFix":"// before\n{\"if_hero_needed\": [\"pattern:\"]}\n\n// after\n{\"if_hero_needed\": [\"pattern:hero-split\"]}","handlingStrategy":"validation","validationCode":"for a in all_actions:\n    prefix, _, value = a.partition(\":\")\n    if prefix == \"pattern\" and not value.strip():\n        raise ValueError(f\"pattern action missing a name: {a!r}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ban placeholder actions in review: run a lint that rejects values matching r'^\\s*$'.","Fill template rule blocks completely or delete the action before saving."],"tags":["decision-rules","pattern","empty-value","validation"],"backgroundTag":null,"analyzedSha":"a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5","analyzedAt":"2026-08-14T18:51:02.321Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}