algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

Sending undefined in initIndex() function is creates and index with "undefined" name

Open anshulsahni opened this issue 3 years ago • 1 comments

While initialising the index - means calling initIndex() if no argument is sent then it considers index name as "undefined" and sends the request to algolia platform with index name value defined as undefined. Of course, the index of that name wouldn't exist in most of the systems, hence it creates a new index with the name undefined.

This is leading to two problems

  1. if the variable containing the index name is not having a value due to some bug, it's not possible to detect because initIndex() function is not throwing an error
  2. Unnecessarily, an index is created in the Algolia dashboard with an unwanted name, making it again very hard to detect or debug an issue

IMO initIndex() behaviour should be to raise an exception in case the value of the index name passed as an argument is undefined, null or an empty string

anshulsahni avatar Oct 01 '22 18:10 anshulsahni

We faced the same issue. We had a bug in our system that we lost the name of the index and sent data to the undefined index. It definitely should throw an error.

egorkel-altexsoft avatar Feb 14 '24 12:02 egorkel-altexsoft