reflex-dev/reflex · error · ValueError
f"Invalid size: {size}. Available sizes: {available_sizes}"
Error message
f"Invalid size: {size}. Available sizes: {available_sizes}" What it means
Link size validation: size must be a registered link size; other values (including old 'sm'/'md'/'lg' strings) raise at create time.
Source
Thrown at packages/reflex-components-internal/src/reflex_components_internal/components/base/link.py:103
return super().create(*children, **props)
@staticmethod
def validate_variant(variant: LiteralLinkVariant):
"""Validate the link variant."""
if variant not in LINK_VARIANTS["variant"]:
available_variants = ", ".join(LINK_VARIANTS["variant"].keys())
message = (
f"Invalid variant: {variant}. Available variants: {available_variants}"
)
raise ValueError(message)
@staticmethod
def validate_size(size: LiteralLinkSize):
"""Validate the link size."""
if size not in LINK_VARIANTS["size"]:
available_sizes = ", ".join(LINK_VARIANTS["size"].keys())
message = f"Invalid size: {size}. Available sizes: {available_sizes}"
raise ValueError(message)
def _exclude_props(self) -> list[str]:
return [*super()._exclude_props(), "size", "variant", "show_icon", "render_"]
link = Link.create
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use a size from the error message list (map sm→1, md→2, lg→3)
- Whitelist config-driven size values
- Rely on the Literal type for static checking
Example fix
# before
rx.link("Home", href="/", size="lg")
# after
rx.link("Home", href="/", size="3") Defensive patterns
Strategy: validation
Validate before calling
from reflex_components_internal.components.base.link import LINK_VARIANTS
if size not in LINK_VARIANTS['size']:
size = '2' Type guard
def is_valid_link_size(s: str) -> TypeGuard[str]:
from reflex_components_internal.components.base.link import LINK_VARIANTS
return s in LINK_VARIANTS['size'] Prevention
- Map sm/md/lg to '1'/'2'/'3' when migrating
- Validate dynamic size props against the registry
When it happens
Trigger: rx.link(..., size="lg") where the numeric radix-style scale ("1"-"4") is expected.
Common situations: Chakra-style sizes left over after upgrading Reflex; sizes sourced from user/theme config without validation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- f"Invalid size: {size}. Available sizes: {available_sizes}"
- f"Invalid variant: {variant}. Available variants: {available
- f"Invalid size: {size}. Available sizes: {available_sizes}"
- Link without a child will not display
- ChildrenTypeError(component=cls.__name__, child=child)
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/0d1daa0d03493d99.
Report an issue: GitHub.