Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Algolia failed: report is not defined #8

Open
stefanisarie opened this issue Feb 3, 2021 · 4 comments
Open

Error: Algolia failed: report is not defined #8

stefanisarie opened this issue Feb 3, 2021 · 4 comments

Comments

@stefanisarie
Copy link

Hi there!

Thank you for taking time to port this plugin and contributing to Gridsome's plugin ecosystem. I was following your instruction of how to setup this plugin with my project. When I build the project however, I'm getting the following error:

Algolia collection #0: Executing query
Error: Algolia failed: report is not defined

I've searched the internet for a meaning of this error, found none! Can you please let me know what am I doing wrong?

Thank you, once again!

@Healios
Copy link

Healios commented Feb 9, 2021

I am getting the same error. There clearly is an issue with the plugin, but the reason it's being discovered, seems to be that @stefanisarie and I have some issues with our "collections" definition.

I have now fixed my issues, but the issue with "report is not defined", still remains.

@ojoanalogo
Copy link

I'm getting the same error but only when I try to upload a list to the Algolia definition
My markdown file

---
title: DevSpace
description: Comunidad de desarrollo
tags: [ 'Programación','Ciencia','Emprendimiento' ]
---

My collections object:

const collections = [
  {
    query: `{
      allCommunity {
        edges {
          node {
            id
            title
            path
            description
            image
            tags
          }
        }
      }
    }`,
    transformer: ({ data }) => data.allCommunity.edges.map(({ node }) => node),
    indexName: process.env.ALGOLIA_INDEX_NAME || "communities", // Algolia index name
    itemFormatter: (item) => {
      return {
        objectID: item.id,
        title: item.title,
        path: item.path,
        description: item.description,
        image: item.image,
        tags: item.tags,
      };
    },
  },
];

A long as I don't use the tags property it will work

@bauhem
Copy link

bauhem commented Sep 21, 2021

Hi, we also get this random error too.

Netlify error :
9:40:57 AM: Algolia collection #80: Executing query
9:40:57 AM: Error: Algolia failed: report is not defined
9:40:57 AM: at /opt/build/repo/node_modules/gridsome-plugin-algolia/index.js:184:13
9:40:57 AM: at processTicksAndRejections (node:internal/process/task_queues:96:5)
9:40:57 AM: at async Plugins.run (/opt/build/repo/node_modules/gridsome/lib/app/Plugins.js:141:11)
9:40:57 AM: at async module.exports (/opt/build/repo/node_modules/gridsome/lib/build.js:42:3)

9:40:57 AM: Algolia collection #26: items in collection 0
9:40:57 AM: Algolia collection #26: starting Partial updates

Our query
const companiesImport = () => {
const MAX = 8000;
const limit = 100;
let skip = 0;
let keepQuerying = true;
let collections = [];

while (keepQuerying) {
const pageQuery = { allCompanies(orderBy: name_ASC, first: ${limit}, skip: ${skip},filter: {_isValid: {eq: "true"}, listingAgent: {exists: "true"}, _status: {eq: published}}){ id _publishedAt _createdAt name description listingAgent { name image { url } } stage { title surtitle slug _modelApiKey } slug area { title slug id } companyType { title id } source { title slug id } companyStatus { title surtitle slug id } industries { title surtitle slug id } city address state zip image { url } views }};

collections.push({
  query: pageQuery,
  transformer: ({ data }) => data.allCompanies,
  indexName: `${process.env.ALGOLIA_INDEX_NAME}` || 'Karleki',
  itemFormatter: (item) => {
    return {
      objectID: item.id,
      name: item.name,
      area: item.area,
      description: item.description,
      agent: item.listingAgent,
      industries: item.industries,
      industriesTitle0: item.industries[0].title,
      stage: item.stage,
      source: item.source,
      city: item.city,
      state: item.state,
      companyType: item.companyType.title,
      companyStatus: item.companyStatus,
      image: item.image.url,
      slug: item.slug,
      modified: String(item._publishedAt),
      createdAt: String(item._createdAt),
      views: item.views
    }
  },
  matchFields: ['slug', 'modified'],
});

skip += limit;
if (skip > MAX) {
  keepQuerying = false
}

}

return collections
};

module.exports = companiesImport();

Our plugins
{ use: 'gridsome-plugin-algolia', options: { appId: process.env.ALGOLIA_APP_ID, apiKey: process.env.ALGOLIA_ADMIN_KEY, collections: companiesImport, chunkSize: 10000, // default: 1000 enablePartialUpdates: true, // default: false }, },

@cprestoncowart
Copy link
Contributor

I opened a PR to fix this: #12

This happens when there's something wrong with executing the query, but the plugin isn't able to provide a more helpful error message. If anyone is seeing this error, it's probably because there's something wrong with the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants