algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

Push to tmp index causes failure with index restriction for API key #18

Closed straight-shoota closed 8 years ago

straight-shoota commented 8 years ago

My first steps combining jekyll with algolia resulted in the following error message:

Cannot PUT to https://E7UT30N10W.algolia.net/1/indexes/glaubenskurs.bonifati.us_tmp/settings: {"message":"Invalid Application-ID or API key","status":403}

When I tried to put some settings with curl there was no problem, neither with directly using the ruby lib. Only after replaying the exact same requests with curl I figured that my API key simply has no access to the temporary index "#{index_name}_tmp" which is automatically used by this gem. My solution was to manually create the temporary index and issue a new API key with access to both the main and temporary indices (using a wildcard should also be possible).

This is of course not an issue for unrestricted API keys. But when you want to restrict your API key to specific indices, this behaviour requires some special attention. I'd suggest to put a notice in the README and maybe provide a error message with a hint in case index.set_settings fails with a 403.

pixelastic commented 8 years ago

Oh you're right. It pushes to a _tmp index and then rename it to do an atomic replacement, so it means your key should have acces to both indices (using * wildcard, as you suggested).

Thanks for the report, I'll add a notice to the readme and try to provide better error messages :)

pixelastic commented 8 years ago

I've update the readme, and pushed v0.6.1 to RubyGems that adds the following error message if it detects that the key does not have access to the _tmp index.

image

Thanks for the report and for helping me make this plugin better :)