{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/json/commands.py#L28-L64","documentation":"Raised by FPHAType.from_value() when the fpha argument to JSON.set does not match any of the four supported floating-point homogenous-array types: BF16, FP16, FP32, FP64. Lookup is case-insensitive (value.upper()) but must equal one of those exact strings. The error message lists the valid values.","triggerScenarios":"Call client.json().set(name, path, obj, fpha=\"FP8\") or any string not in {BF16, FP16, FP32, FP64} (case-insensitive), or pass a non-string that has no .upper() and isn't an FPHAType instance.","commonSituations":"Typo in a config-driven fpha value; passing a type the server doesn't support (e.g. 'INT8', 'F8'); version mismatch — fpha is a newer RedisJSON feature, so older modules simply don't know these names.","solutions":["Use one of the four valid values: 'BF16', 'FP16', 'FP32', 'FP64' (or the FPHAType enum members).","Pass None or omit fpha to let Redis pick the native type.","Validate the value against the FPHAType enum before calling set()."],"exampleFix":"// before\nclient.json().set(\"k\", \"$\", obj, fpha=\"FP8\")\n// after\nfrom redis.commands.json.commands import FPHAType\nclient.json().set(\"k\", \"$\", obj, fpha=FPHAType.BF16)","handlingStrategy":"type-guard","validationCode":"from redis.commands.json.commands import FPHAType\n\ndef coerce_fpha(v):\n    if v is None:\n        return None\n    return FPHAType.from_value(v)  # raises DataError with the valid list\n\nfpha = coerce_fpha(user_input)\nclient.json().set(\"k\", \"$\", obj, fpha=fpha)","typeGuard":"from redis.commands.json.commands import FPHAType\n\ndef is_valid_fpha(v) -> bool:\n    try:\n        FPHAType.from_value(v)\n        return True\n    except Exception:\n        return False","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.json().set(\"k\", \"$\", obj, fpha=raw)\nexcept DataError as e:\n    if \"Invalid FPHA type\" in str(e):\n        # fall back to native storage\n        client.json().set(\"k\", \"$\", obj)\n    else:\n        raise","preventionTips":["Always pass the FPHAType enum rather than a raw string.","If accepting strings from users, validate against FPHAType before calling set().","Remember fpha only applies to homogeneous float arrays; omit it otherwise."],"tags":["redis-json","validation","fpha","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}