{"record":{"id":"a74d72aac28c0a0c","repo":"redis/redis-rb","slug":"fields-must-not-be-empty","errorCode":null,"errorMessage":"fields must not be empty","messagePattern":"fields must not be empty","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/hashes.rb","lineNumber":492,"sourceCode":"      # other connections. See the README \"Bulk hash ingestion (HIMPORT)\"\n      # section for connection-scoping guidance. Re-preparing an existing\n      # +fieldset_name+ silently replaces it. Field order is preserved as\n      # given; it defines the positional pairing used by #himport_set.\n      #\n      # @note HIMPORT support is experimental: the client API may change in a\n      #   future minor release without a major version bump.\n      #\n      # @example\n      #   redis.himport_prepare(\"shared\", [\"name\", \"email\", \"age\"])\n      #     # => \"OK\"\n      #\n      # @param [String] fieldset_name name used by later SET and DISCARD calls\n      # @param [String, Array<String>] fields one or more field names\n      # @return [String] `\"OK\"`\n      # @api experimental\n      def himport_prepare(fieldset_name, *fields)\n        fields.flatten!(1)\n        raise ArgumentError, \"fields must not be empty\" if fields.empty?\n\n        send_command([:himport, \"PREPARE\", fieldset_name].concat(fields))\n      end\n\n      # Create or fully replace the hash at +key+ using the field list\n      # registered under +fieldset_name+ on this connection. Values pair\n      # positionally with the fields given to #himport_prepare; the value\n      # count must equal the field count.\n      #\n      # The fieldset must exist on the executing connection, otherwise the\n      # server replies with a \"no such fieldset\" error.\n      #\n      # @note HIMPORT support is experimental: the client API may change in a\n      #   future minor release without a major version bump.\n      #\n      # @example\n      #   redis.himport_set(\"shared:1\", \"shared\", [\"alice\", \"alice@example.com\", \"25\"])\n      #     # => \"OK\"","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/hashes.rb#L474-L510","documentation":"himport_prepare registers a named fieldset for the HIMPORT command family as per-connection session state on the server. After flattening its *fields argument it requires at least one field name; an empty list — no arguments, a single empty array, or an empty computed list — raises ArgumentError 'fields must not be empty' client-side.","triggerScenarios":"redis.himport_prepare('schema') with no fields; redis.himport_prepare('schema', []); a fields array built at runtime (e.g. columns.select { ... }) that matched nothing and flattens to [].","commonSituations":"Dynamic schemas derived from model attributes or query results that can legitimately be empty; refactoring a fixed field list into a variable without adding a guard.","solutions":["Pass at least one field: redis.himport_prepare('shared', 'name', 'email') or an array like redis.himport_prepare('shared', %w[name email])","Guard dynamic lists at the construction site and raise a domain-specific error naming the empty source","Remember fieldsets are per-connection state: after reconnect/failover re-prepare (the client auto-repairs via himport_auto_prepare unless disabled)"],"exampleFix":"# before\nfields = []  # e.g. computed from user input\nredis.himport_prepare('shared', fields)  # ArgumentError\n\n# after\nraise ArgumentError, 'no fields selected' if fields.empty?\nredis.himport_prepare('shared', *fields)","handlingStrategy":"validation","validationCode":"fields = Array(fields).flatten\nraise ArgumentError, 'no fields to register' if fields.empty?\nredis.himport_prepare(fieldset_name, *fields)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate schema lists at construction time with a domain-specific error","Flatten and compact computed field lists before passing them","Remember the fieldset is per-connection session state; re-prepare after reconnects"],"tags":["argument-validation","himport","hashes","empty-argument"],"backgroundTag":"empty-argument-list","analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}