{"record":{"id":"a612497737d0ea10","repo":"redis/redis-rb","slug":"schema-must-be-a-schema-object","errorCode":null,"errorMessage":"schema must be a Schema object","messagePattern":"schema must be a Schema object","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/modules/search/miscellaneous.rb","lineNumber":44,"sourceCode":"      # @param max_text_fields [Boolean] emit +MAXTEXTFIELDS+\n      # @param skip_initial_scan [Boolean] emit +SKIPINITIALSCAN+ (do not backfill existing keys)\n      # @param definition [Search::IndexDefinition, nil] a prebuilt +ON .../PREFIX/FILTER/...+ clause;\n      #   when given it takes precedence over +storage_type+/+prefix+\n      # @param temporary [Integer, nil] index lifetime in seconds (emits +TEMPORARY <seconds>+)\n      # @param no_term_offsets [Boolean] emit +NOOFFSETS+\n      # @param no_highlight [Boolean] emit +NOHL+\n      # @param no_field_flags [Boolean] emit +NOFIELDS+\n      # @param no_term_frequencies [Boolean] emit +NOFREQS+\n      # @return [String] +\"OK\"+\n      # @raise [ArgumentError] if +schema+ is not a {Search::Schema}\n      def ft_create(\n        index_name, schema, storage_type = nil,\n        prefix: nil, stopwords: nil, max_text_fields: false,\n        skip_initial_scan: false, definition: nil, temporary: nil,\n        no_term_offsets: false, no_highlight: false,\n        no_field_flags: false, no_term_frequencies: false, **_options\n      )\n        raise ArgumentError, \"schema must be a Schema object\" unless schema.is_a?(Schema)\n\n        args = [index_name]\n\n        # Use IndexDefinition if provided, otherwise use legacy parameters\n        if definition\n          # The definition supplies the ON/PREFIX/FILTER clause. When it doesn't declare an index\n          # type, fall back to the storage_type keyword so e.g. a JSON index isn't silently created\n          # as HASH. Normalize to the uppercase HASH/JSON form some Query Engine versions require.\n          args += [\"ON\", storage_type.to_s.upcase] if definition.index_type.nil? && storage_type\n          args += definition.args\n        else\n          # Normalize the ON token to HASH/JSON; a lowercase value is rejected by some\n          # Query Engine versions (and IndexType/the docs use the uppercase form).\n          args += [\"ON\", storage_type.to_s.upcase] if storage_type\n          args += [\"PREFIX\", 1, \"#{prefix}:\"] if prefix\n        end\n\n        args << \"MAXTEXTFIELDS\" if max_text_fields","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/modules/search/miscellaneous.rb#L26-L62","documentation":"Error \"schema must be a Schema object\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/commands/modules/search/miscellaneous.rb:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a Schema object (built via the schema DSL) instead of a hash or array.","Construct the schema first, e.g. Schema.new { |s| s.text_field(:title) }, and pass that instance."],"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"}