nextlevelbuilder/ui-ux-pro-max-skill · error · ValueError
{} must map to a non-empty action array
Error message
{} must map to a non-empty action array What it means
Every condition key in the decision-rule object must map to a non-empty JSON array of action strings. Mapping to a scalar, an object, an empty array [], or null raises this ValueError naming the condition. Empty arrays are rejected because a condition that activates but does nothing is indistinguishable from a mistake.
Source
Thrown at src/ui-ux-pro-max/scripts/reasoning_contract.py:79
if key in result:
raise ValueError("duplicate decision-rule key: {}".format(key))
result[key] = value
return result
def parse_decision_rules(raw):
"""Parse the canonical condition -> action-array representation."""
try:
rules = json.loads(raw or "{}", object_pairs_hook=_object_without_duplicates)
except json.JSONDecodeError as error:
raise ValueError("invalid decision-rule JSON: {}".format(error)) from error
if not isinstance(rules, dict):
raise ValueError("decision rules must be a JSON object")
for condition, actions in rules.items():
if condition not in ALLOWED_CONDITIONS:
raise ValueError("unknown decision-rule condition: {}".format(condition))
if not isinstance(actions, list) or not actions:
raise ValueError("{} must map to a non-empty action array".format(condition))
for action in actions:
_validate_action(action)
if len(actions) != len(set(actions)):
raise ValueError("{} contains duplicate actions".format(condition))
return rules
def _validate_action(action):
if not isinstance(action, str) or ":" not in action:
raise ValueError("action must use a known prefix: {}".format(action))
prefix, value = action.split(":", 1)
if prefix not in ACTION_PREFIXES:
raise ValueError("unknown decision-rule action: {}".format(action))
if prefix in TOKEN_ACTION_PREFIXES and not TOKEN_RE.fullmatch(value):
raise ValueError("invalid {} action value: {}".format(prefix, value))
if prefix == "pattern" and not value.strip():
raise ValueError("pattern action must name a pattern")
if prefix == "mode" and value not in {"dark", "light"}:View on GitHub (pinned to a38d04c3d5)
Solutions
- Wrap actions in an array: "mode:dark" becomes ["mode:dark"].
- Delete the condition key entirely if it should have no actions.
- Ensure each element is an action string — the array shape is validated further by _validate_action.
Example fix
// before
{"if_mobile": "mode:dark", "if_luxury": []}
// after
{"if_mobile": ["mode:dark"]} Defensive patterns
Strategy: validation
Validate before calling
import json
rules = json.loads(raw)
for cond, actions in rules.items():
if not isinstance(actions, list) or not actions:
raise ValueError(f"{cond} must map to a non-empty list; got {actions!r}") Type guard
def is_non_empty_action_list(value) -> bool:
return isinstance(value, list) and len(value) > 0 and all(isinstance(a, str) for a in value) Prevention
- Delete condition keys that no longer apply instead of emptying their arrays.
- Keep single actions wrapped in brackets in templates and examples so the array shape is never 'simplified'.
When it happens
Trigger: parse_decision_rules('{"if_mobile": "mode:dark"}') (string not array), '{"must_have": []}' (empty), '{"if_luxury": {"style":"luxury-gold"}}' (object), or '{"if_booking": null}'.
Common situations: Compressing a single action to a scalar for brevity; clearing a rule by emptying its array instead of deleting the key; a schema drift where actions were once objects.
Related errors
- duplicate decision-rule key: {}
- decision rules must be a JSON object
- {} contains duplicate actions
- Invalid JSON file {path}: {error}
- invalid decision-rule JSON: {}
AI-assisted analysis of nextlevelbuilder/ui-ux-pro-max-skill@a38d04c3d5 (2026-08-14).
Data as JSON: /api/errors/bc66763b87201d7a.
Report an issue: GitHub.