{"record":{"id":"ff8dbcb5d7846571","repo":"reflex-dev/reflex","slug":"the-condition-must-be-set-ff8dbc","errorCode":null,"errorMessage":"The condition must be set","messagePattern":"The condition must be set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/core/match.py","lineNumber":82,"sourceCode":"\n    @classmethod\n    def _create_condition_var(cls, cond: Any) -> Var:\n        \"\"\"Convert the condition to a Var.\n\n        Args:\n            cond: The condition.\n\n        Returns:\n            The condition as a base var\n\n        Raises:\n            ValueError: If the condition is not provided.\n        \"\"\"\n        match_cond_var = LiteralVar.create(cond)\n\n        if match_cond_var is None:\n            msg = \"The condition must be set\"\n            raise ValueError(msg)\n        return match_cond_var\n\n    @classmethod\n    def _process_cases(\n        cls, cases: list\n    ) -> tuple[list[tuple], Var | BaseComponent | None]:\n        \"\"\"Process the list of match cases and the catchall default case.\n\n        Args:\n            cases: The list of match cases.\n\n        Returns:\n            The default case and the list of match case tuples.\n\n        Raises:\n            ValueError: If there are multiple default cases.\n        \"\"\"\n        if not cases:","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/core/match.py#L64-L100","documentation":"The first argument to `rx.match` must be convertible to a Var. If `LiteralVar.create(cond)` returns None (None condition or an unsupported type), the condition is unusable and match cannot compare against any cases.","triggerScenarios":"`rx.match(None, ...)`; passing a raw Python object LiteralVar can't serialize (arbitrary class instance, file handle); a refactor leaves the condition expression blank.","commonSituations":"Matching on an optional field that may be None without a guard; passing untyped API payloads directly as the match condition.","solutions":["Pass a State var or literal: rx.match(State.kind, ...)","Guard None first: rx.match(cond or 'default', ...) or wrap with rx.cond(cond is not None, rx.match(cond, ...), fallback)","Use values of supported types (str/int/bool/Var/comparisons)"],"exampleFix":"# before\nrx.match(get_status(), ('ok', 'OK'), 'other')  # may return None\n# after\nrx.match(State.status or 'unknown', ('ok', 'OK'), 'other')","handlingStrategy":"type-guard","validationCode":"cond_var = State.kind if State.kind is not None else 'default'\nresult = rx.match(cond_var, ('a', 1), 0)","typeGuard":"def is_matchable(c) -> bool:\n    return c is not None and isinstance(c, (str, int, float, bool, Var))","tryCatchPattern":null,"preventionTips":["Guard optional match conditions against None","Match on typed state vars or literals only"],"tags":["reflex","match","missing-condition-expression"],"backgroundTag":"missing-condition-expression","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}