{"record":{"id":"751ff85f17a9a112","repo":"reflex-dev/reflex","slug":"f-invalid-size-size-available-sizes-availabl","errorCode":null,"errorMessage":"f\"Invalid size: {size}. Available sizes: {available_sizes}\"","messagePattern":"f\"Invalid size: (.+?)\\. Available sizes: (.+?)\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-internal/src/reflex_components_internal/components/base/button.py","lineNumber":130,"sourceCode":"        return super().create(*children_list, **props)\n\n    @staticmethod\n    def validate_variant(variant: LiteralButtonVariant):\n        \"\"\"Validate the button variant.\"\"\"\n        if variant not in BUTTON_VARIANTS[\"variant\"]:\n            available_variants = \", \".join(BUTTON_VARIANTS[\"variant\"].keys())\n            message = (\n                f\"Invalid variant: {variant}. Available variants: {available_variants}\"\n            )\n            raise ValueError(message)\n\n    @staticmethod\n    def validate_size(size: LiteralButtonSize):\n        \"\"\"Validate the button size.\"\"\"\n        if size not in BUTTON_VARIANTS[\"size\"]:\n            available_sizes = \", \".join(BUTTON_VARIANTS[\"size\"].keys())\n            message = f\"Invalid size: {size}. Available sizes: {available_sizes}\"\n            raise ValueError(message)\n\n    def _exclude_props(self) -> list[str]:\n        return [\n            *super()._exclude_props(),\n            \"size\",\n            \"variant\",\n            \"loading\",\n        ]\n\n\nclass ButtonNamespace(ComponentNamespace):\n    \"\"\"Namespace for Button components.\"\"\"\n\n    create = staticmethod(Button.create)\n    class_names = ClassNames\n    __call__ = staticmethod(Button.create)\n\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-internal/src/reflex_components_internal/components/base/button.py#L112-L148","documentation":"Button size must be one of the registered sizes (e.g. 1-4 in radix-style or sm/md/lg mappings). Any other string fails validation at create time.","triggerScenarios":"rx.button(..., size=\"medium\") or size=\"xl\" — not in BUTTON_VARIANTS['size']; commonly old Chakra sizes (sm/md/lg/xl).","commonSituations":"Porting Chakra-based Reflex apps where sizes were 'sm'/'md'/'lg'; typos; sizes coming from CMS/config data.","solutions":["Use a listed size from the error message (map md→'2', lg→'3', sm→'1' as appropriate)","Validate/whitelist config-driven sizes before passing them","Use the Literal size type from the package for static checking"],"exampleFix":"# before\nrx.button(\"Hi\", size=\"md\")\n# after\nrx.button(\"Hi\", size=\"2\")","handlingStrategy":"validation","validationCode":"from reflex_components_internal.components.base.button import BUTTON_VARIANTS\nif size not in BUTTON_VARIANTS['size']:\n    size = '2'  # default fallback","typeGuard":"def is_valid_button_size(s: str) -> TypeGuard[str]:\n    from reflex_components_internal.components.base.button import BUTTON_VARIANTS\n    return s in BUTTON_VARIANTS['size']","tryCatchPattern":null,"preventionTips":["Use numeric radix sizes ('1'-'4')","Whitelist config-driven sizes before passing"],"tags":["reflex","button","size"],"backgroundTag":"invalid-enum-value","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}