{"record":{"id":"0bc958919f22b050","repo":"redis/redis-py","slug":"invalid-fpha-type-value-must-be-one-of-j","errorCode":null,"errorMessage":"Invalid FPHA type: {value}. Must be one of {', '.join(t.value for t in cls)}","messagePattern":"Invalid FPHA type: (.+?)\\. Must be one of (.+?)","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/json/commands.py","lineNumber":46,"sourceCode":"    def from_value(cls, value: \"FPHAType | str\") -> \"FPHAType\":\n        \"\"\"Convert a string or FPHAType instance to a validated FPHAType.\n\n        Args:\n            value: An ``FPHAType`` member or a case-insensitive string\n                (e.g. ``\"bf16\"``, ``\"FP32\"``).\n\n        Returns:\n            The corresponding ``FPHAType`` enum member.\n\n        Raises:\n            DataError: If the string does not match any valid FPHA type.\n        \"\"\"\n        if isinstance(value, cls):\n            return value\n        try:\n            return cls(value.upper())\n        except ValueError:\n            raise DataError(\n                f\"Invalid FPHA type: {value}. \"\n                f\"Must be one of {', '.join(t.value for t in cls)}\"\n            )\n\n\nclass JSONCommands:\n    \"\"\"json commands.\"\"\"\n\n    @overload\n    def arrappend(\n        self: SyncClientProtocol,\n        name: str,\n        path: str | None = Path.root_path(),\n        *args: JsonType,\n    ) -> int | list[int | None] | None: ...\n\n    @overload\n    def arrappend(","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/json/commands.py#L28-L64","documentation":"Raised by FPHAType.from_value() (redis/commands/json/commands.py:46) as a DataError when the fpha argument to JSON SET cannot be matched to one of BF16, FP16, FP32, FP64. Matching is case-insensitive (the input is uppercased), so 'bf16' works but 'bf' or 'FP8' does not.","triggerScenarios":"Calling client.json().set(key, '$', obj, fpha='FP8'), fpha='bf', fpha='fp-16', or any string not in {BF16,FP16,FP32,FP64} regardless of case. Passing the enum member directly always works.","commonSituations":"Typos in the floating-point type name, using an unsupported format like FP8/INT8, or copy-pasting a value from docs that uses a different naming convention.","solutions":["Use one of the exact values BF16, FP16, FP32, or FP64 (case-insensitive), or pass the FPHAType enum member.","Import and pass the enum directly: from redis.commands.json.commands import FPHAType; fpha=FPHAType.FP32.","Drop the fpha argument entirely if you do not need forced FP homogeneous array storage."],"exampleFix":"# before\nclient.json().set('doc', '$', arr, fpha='FP8')\n# after\nfrom redis.commands.json.commands import FPHAType\nclient.json().set('doc', '$', arr, fpha=FPHAType.FP16)","handlingStrategy":"type-guard","validationCode":"from redis.commands.json.commands import FPHAType\n\ndef safe_fpha(value):\n    if value is None:\n        return None\n    if isinstance(value, FPHAType):\n        return value\n    try:\n        return FPHAType[value.upper()] if hasattr(FPHAType, value.upper()) else FPHAType(value.upper())\n    except (KeyError, ValueError):\n        raise ValueError(f'unsupported fpha {value!r}; use one of {[t.value for t in FPHAType]}')","typeGuard":"from redis.commands.json.commands import FPHAType\n\ndef is_valid_fpha(v) -> bool:\n    if isinstance(v, FPHAType):\n        return True\n    return isinstance(v, str) and v.upper() in {t.value for t in FPHAType}","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.json().set('k', '$', obj, fpha=fmt)\nexcept DataError as e:\n    if 'FPHA' in str(e):\n        client.json().set('k', '$', obj)  # proceed without forced FP type\n    else:\n        raise","preventionTips":["Pass the FPHAType enum member directly rather than a string.","Centralize the allowed set: ALLOWED = {t.value for t in FPHAType}.","Drop fpha when you do not specifically need FP homogeneous array storage."],"tags":["json","fpha","argument-validation","dataerror","redisjson"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}