{"record":{"id":"46f9b332c9a62ec6","repo":"reflex-dev/reflex","slug":"shade-must-be-an-integer-or-a-var","errorCode":null,"errorMessage":"Shade must be an integer or a Var","messagePattern":"Shade must be an integer or a Var","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/core/colors.py","lineNumber":47,"sourceCode":"\n    Raises:\n        ValueError: If the color, shade, or alpha are not valid.\n    \"\"\"\n    if isinstance(color, str):\n        if color not in COLORS and REFLEX_VAR_OPENING_TAG not in color:\n            msg = f\"Color must be one of {COLORS}, received {color}\"\n            raise ValueError(msg)\n    elif not isinstance(color, Var):\n        msg = \"Color must be a string or a Var\"\n        raise ValueError(msg)\n\n    if isinstance(shade, int):\n        if shade < MIN_SHADE_VALUE or shade > MAX_SHADE_VALUE:\n            msg = f\"Shade must be between {MIN_SHADE_VALUE} and {MAX_SHADE_VALUE}\"\n            raise ValueError(msg)\n    elif not isinstance(shade, Var):\n        msg = \"Shade must be an integer or a Var\"\n        raise ValueError(msg)\n\n    if not isinstance(alpha, (bool, Var)):\n        msg = \"Alpha must be a boolean or a Var\"\n        raise ValueError(msg)\n\n    return Color(color, shade, alpha)\n","sourceCodeStart":29,"sourceCodeEnd":54,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/core/colors.py#L29-L54","documentation":"The `shade` parameter of `rx.color()` accepts only an `int` (0–12) or a `Var`. Any other type — string like '7', float, None, bool-adjacent values — is rejected by this isinstance check.","triggerScenarios":"`rx.color('red', '7')` (shade read from a config string), `rx.color('red', 7.0)`, or `rx.color('red', None)`.","commonSituations":"Reading shade from environment variables, JSON, or query params which yield strings; forgetting that the parameter is positional after color.","solutions":["Convert to int: rx.color('red', int(shade_str))","If the shade is dynamic/state-driven, pass a Var (e.g. State.shade as rx.Var[int])","Provide the shade explicitly rather than defaulting to a non-int sentinel"],"exampleFix":"// before\nrx.color('red', shade=config['shade'])  # str\n// after\nrx.color('red', shade=int(config['shade']))","handlingStrategy":"validation","validationCode":"shade = int(shade) if isinstance(shade, str) else shade\nif not isinstance(shade, (int, Var)):\n    raise TypeError('shade must be int or Var')","typeGuard":"def is_shade(s) -> bool:\n    return isinstance(s, (int, Var)) and not isinstance(s, bool)","tryCatchPattern":null,"preventionTips":["Convert config/env strings to int before use","Annotate shade-holding fields as int"],"tags":["reflex","color","type-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}