{"record":{"id":"e6b79100df3cb34d","repo":"redis/redis-rb","slug":"fpha-accepts-only-json-set-fpha-types-join","errorCode":null,"errorMessage":"fpha accepts only: #{JSON_SET_FPHA_TYPES.join(', ')}","messagePattern":"fpha accepts only: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/modules/json.rb","lineNumber":100,"sourceCode":"      # @param [Boolean] raw treat +value+ as an already-encoded JSON string and send it as-is\n      # @param [String, Symbol] fpha store a numeric array as a Floating-Point\n      #   Homogeneous Array of the given precision — one of +:bf16+, +:fp16+,\n      #   +:fp32+, +:fp64+ (case-insensitive; Redis 8.8+). All values of the array\n      #   are forced into the fixed floating-point type: +:bf16+/+:fp16+ halve\n      #   memory at reduced precision, while +:fp32+/+:fp64+ keep higher precision.\n      # @return [Boolean, String] when +nx+ or +xx+ is given, +true+ on success and +false+\n      #   when the condition was not met; otherwise the raw +\"OK\"+ reply\n      # @raise [ArgumentError] if both +nx+ and +xx+ are given (they are mutually exclusive),\n      #   or if +fpha+ is not one of the supported types\n      # @raise [Redis::CommandError] if a value in the array does not fit the chosen\n      #   +fpha+ type (\"value out of range for ...\")\n      def json_set(key, path, value, nx: false, xx: false, raw: false, fpha: nil)\n        raise ArgumentError, \"nx and xx are mutually exclusive\" if nx && xx\n\n        if fpha\n          fpha = fpha.to_s.upcase\n          unless JSON_SET_FPHA_TYPES.include?(fpha)\n            raise ArgumentError, \"fpha accepts only: #{JSON_SET_FPHA_TYPES.join(', ')}\"\n          end\n        end\n\n        value = ::JSON.generate(value) unless raw\n        args = [:\"JSON.SET\", key, path, value]\n        args << \"NX\" if nx\n        args << \"XX\" if xx\n        args << \"FPHA\" << fpha if fpha\n\n        if nx || xx\n          send_command(args, &BoolifySet)\n        else\n          send_command(args)\n        end\n      end\n\n      # Get the JSON value(s) at one or more +paths+ in the document stored under +key+.\n      #","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/modules/json.rb#L82-L118","documentation":"The fpha option tells JSON.SET to store a numeric array as a server-side Floating-Point Homogeneous Array: fixed-precision, memory-efficient vector storage (Redis 8.8+). Only four precisions exist: BF16, FP16, FP32, FP64. The value is upcased before comparison, so :fp32, \"fp32\" and \"FP32\" all work; anything else raises ArgumentError client-side with the accepted list in the message (lib/redis/commands/modules/json.rb:100).","triggerScenarios":"redis.json_set(\"doc\", \"$.v\", [0.1, 0.2], fpha: :float32); fpha: \"fp8\"; fpha: \"f64\"; a typo such as fpha: \"FP_32\".","commonSituations":"Confusing FPHA precision names with the FLOAT32 element type used in FT.SEARCH vector fields (float32 is wrong here, fp32 is right); assuming every IEEE or 8-bit float format is supported; passing fpha on a server older than Redis 8.8, which passes client validation but fails later with a server-side syntax error.","solutions":["Use one of :bf16, :fp16, :fp32, :fp64 (any case, symbol or string)","Map FLOAT32-style input to :fp32 before calling json_set","Gate FPHA usage on a Redis 8.8+ version check so the server-side failure mode is also caught"],"exampleFix":"// before\nredis.json_set(\"doc\", \"$\", vec, fpha: \"float32\")\n// after\nredis.json_set(\"doc\", \"$\", vec, fpha: :fp32)","handlingStrategy":"validation","validationCode":"FPHA_TYPES = %w[BF16 FP16 FP32 FP64].freeze\n\ndef store_vector(redis, key, path, vec, fpha: :fp32)\n  fpha = fpha.to_s.upcase\n  raise ArgumentError, \"fpha must be one of #{FPHA_TYPES.join(\", \")}\" unless FPHA_TYPES.include?(fpha)\n  redis.json_set(key, path, vec, fpha: fpha)\nend","typeGuard":"fpha.nil? || %w[BF16 FP16 FP32 FP64].include?(fpha.to_s.upcase)","tryCatchPattern":"begin\n  redis.json_set(k, p, v, fpha: fpha)\nrescue ArgumentError => e\n  raise ConfigError, e.message\nend","preventionTips":["Whitelist fpha at the config boundary with %w[BF16 FP16 FP32 FP64]","Remember fpha accepts only fp-prefixed names, not FLOAT32","Gate FPHA usage on a Redis 8.8+ version check"],"tags":["redis-json","fpha","vector","argumenterror","client-side-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}