{"record":{"id":"9533b9a5c9f90f09","repo":"reflex-dev/reflex","slug":"otp-field-length-is-required-when-passing-childr","errorCode":null,"errorMessage":"OTP field `length` is required when passing children explicitly.","messagePattern":"OTP field `length` is required when passing children explicitly\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-internal/src/reflex_components_internal/components/base/otp_field.py","lineNumber":179,"sourceCode":"\n        Args:\n            *children: Optional children to include in place of the default inputs.\n            **props: Additional properties to apply to the OTP field root.\n\n        Returns:\n            The OTP field component.\n\n        Raises:\n            ValueError: If `length` is missing when children are supplied, or\n                if `length` is not a positive integer when children are\n                auto-generated.\n            TypeError: If `length` is not an integer when children are\n                auto-generated (a Var can only be used with explicit children).\n        \"\"\"\n        if children:\n            if \"length\" not in props:\n                msg = \"OTP field `length` is required when passing children explicitly.\"\n                raise ValueError(msg)\n        else:\n            length = props.setdefault(\"length\", 6)\n            if not isinstance(length, int) or isinstance(length, bool):\n                msg = (\n                    \"OTP field high-level wrapper requires a static integer `length`.\"\n                    \" Pass children explicitly for dynamic lengths.\"\n                )\n                raise TypeError(msg)\n            if length <= 0:\n                msg = \"OTP field `length` must be a positive integer.\"\n                raise ValueError(msg)\n            children = tuple(OTPFieldInput.create() for _ in range(length))\n\n        return OTPFieldRoot.create(*children, **props)\n\n\nclass OTPField(ComponentNamespace):\n    \"\"\"Namespace for OTP field components.\"\"\"","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-internal/src/reflex_components_internal/components/base/otp_field.py#L161-L197","documentation":"The OTP field wrapper auto-generates length input slots only when you pass no children; with explicit children it cannot infer the count, so you must pass length explicitly (as a static int) so it can wire up paste/caret behavior.","triggerScenarios":"rx.otp_field(rx.otp_field.slot(), rx.otp_field.slot()) without length=4 — children given but length omitted.","commonSituations":"Customizing slot rendering (custom separators, styling) by passing children manually and forgetting length; trying to use a Var length (not allowed without static behavior).","solutions":["Pass an explicit integer: rx.otp_field(*slots, length=4)","Or pass no children and use length=N (default 6) to auto-generate slots","Remember length must be a static int when children are auto-generated; only explicit-children mode needs the prop here"],"exampleFix":"# before\nrx.otp_field(rx.otp_field.slot(), rx.otp_field.slot())\n# after\nrx.otp_field(rx.otp_field.slot(), rx.otp_field.slot(), length=2)","handlingStrategy":"validation","validationCode":"if children and 'length' not in kwargs:\n    kwargs['length'] = len(children)\nrx.otp_field(*children, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass length=N whenever you pass explicit slot children","Use auto-generated slots (no children) for the common case"],"tags":["reflex","otp-field","required-prop"],"backgroundTag":"missing-required-prop","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}