{"record":{"id":"7ed89a0e7539496e","repo":"redis/redis-rb","slug":"field-or-args-must-be-a-field-object-or-an-array","errorCode":null,"errorMessage":"field_or_args must be a Field object or an array","messagePattern":"field_or_args must be a Field object or an array","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/modules/search/miscellaneous.rb","lineNumber":356,"sourceCode":"      def ft_explain(index_name, query)\n        send_command([\"FT.EXPLAIN\", index_name, query])\n      end\n\n      # Add a field to an existing index's schema (+FT.ALTER ... SCHEMA ADD+).\n      #\n      # @param index_name [String] the index name\n      # @param field_or_args [Search::Field, Array] a {Search::Field} (rendered via +#to_args+) or a\n      #   raw token array\n      # @return [String] +\"OK\"+\n      # @raise [ArgumentError] if +field_or_args+ is neither a Field nor an Array\n      def ft_alter(index_name, field_or_args)\n        args = [index_name, \"SCHEMA\", \"ADD\"]\n        if field_or_args.respond_to?(:to_args)\n          args += field_or_args.to_args\n        elsif field_or_args.is_a?(Array)\n          args += field_or_args\n        else\n          raise ArgumentError, \"field_or_args must be a Field object or an array\"\n        end\n        send_command([:\"FT.ALTER\", *args])\n      end\n\n      # Read the next batch of results from an aggregation cursor.\n      #\n      # @param index_name [String] the index name\n      # @param cursor_id [Integer] the cursor id returned by a previous WITHCURSOR aggregation\n      # @return [Search::AggregateResult] the next rows, with +#cursor+ set to the next cursor id\n      #   (+0+ when exhausted)\n      def ft_cursor_read(index_name, cursor_id)\n        send_command([\"FT.CURSOR\", \"READ\", index_name, cursor_id]) { |reply| ResultParser.aggregate(reply) }\n      end\n\n      # Discard an aggregation cursor.\n      #\n      # @param index_name [String] the index name\n      # @param cursor_id [Integer] the cursor id","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/modules/search/miscellaneous.rb#L338-L374","documentation":"Error \"field_or_args must be a Field object or an array\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/modules/search/miscellaneous.rb:356 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a single Field object or an array of Field objects to the method.","Convert raw hashes into Field objects before calling."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}