"AlgoliaSearchError: Unknown error" on Netlify build

I’m trying to build a React app in Netlify, but the Algolia Search elements fail on build, but the error code is difficult to diagnose.

Here is the error code:

    Algolia: 1 queries to index
    Algolia: query 0: executing query
    Algolia: query 0: graphql resulted in 2685 records
    Algolia: query 0: starting Partial updates
    Algolia: query 0: found 2685 existing records
    Algolia: query 0: Partial updates – [insert/update: 2685, total: 2685]
    Algolia: query 0: splitting in 1 jobs
    error failed to index to Algolia
    AlgoliaSearchError: Unknown error
    AlgoliaSearchCore.js:377 success
    [site]/[gatsby-plugin-algolia]/[algoliasearch]/src/AlgoliaSearchCore.js:377:    32
    task_queues.js:97 processTicksAndRejections
    - gatsby-node.js:158 
    - async Promise.all
    - gatsby-node.js:162 async doQuery
    - async Promise.all
    - gatsby-node.js:186 async Object.exports.onPostBuild

Repo for the app is here: https://github.com/benrmatthews/goodhere

Let me know if you need any further info to help diagnose the issue.

Hey @ben11 - fellow Algolia user here…welcome to the community!

If your .env.sample is representative of your actual .env file, it looks like you might be using a search-only API key. The plugin docs assume that API key is an admin key.

As a first troubleshooting step, I’d check permissions on the Algolia API key you’re currently using. I’m guessing it has search permissions only. If that’s the case, you’ll need to integrate a second, private key with addObjects permissions for syncing records to Algolia.

Just be mindful of security, aka make sure the addObjects API key stays out of source control AND never makes it to the client. Per the plugin docs:

First add credentials to a .env file, which you won’t commit. If you track this in your file, and especially if the site is open source, you will leak your admin API key. This would mean anyone is able to change anything on your Algolia index.

If you are indeed using an admin key and still getting errors, just report back and we can continue to troubleshoot.

1 Like