algolia/algoliasearch-client-ruby

`get_objects` fails when passing in `attributesToRetrieve`

PFStein opened this issue · 1 comments

  • Algolia Client Version: algolia (2.2.2)
  • Language Version: ruby 2.6.5p114 (2019-10-01 revision 67812) [-darwin21]

Description

When passing in attributesToRetrieve to get_objects we receive an http error stating that attributesToRetrieve is an invalid key. We traced the issue back to the call made to the Algolia API here:

@transporter.read(:POST, '/1/indexes/*/objects', { 'requests': requests }, opts)

We tested that if we pass in request_options instead opts the call works as documented.

Steps To Reproduce

search_config = Algolia::Search::Config.new(
  application_id: 'app_id', api_key: 'api_key', symbolize_keys: false,
)
client = Algolia::Search::Client.new(search_config, { logger: Rails.logger })
index = client.init_index('my_index')
index.get_objects(['1'], { attributesToRetrieve: ["id"] })
# Fails with invalid key 'attributesToRetrieve'. Expected: appID, apiKey, requests (near 1:121)

Additionally, it would be nice to use opts.dup on the parameter to avoid mutating a potentially frozen options hash.