algolia / jekyll-algolia

Add fast and relevant search to your Jekyll site
https://community.algolia.com/jekyll-algolia/
MIT License
214 stars 35 forks source link

build fails with "Error: no implicit conversion of String into Integer" but --dry-run flag says "Indexing Complete" instead #162

Open cj-peach opened 3 years ago

cj-peach commented 3 years ago

EDIT I've found the cause/solution to the bug I initially reported, so am adjusting this to a feature request:

I want to suggest a feature:

Settings should be validated before attempting to push data and meaningful feedback provided to allow someone to adjust bad config.

What is your use case for such a feature?

The original issue is fully outlined below. To summarize: a setting in the config was in the wrong format (a number was wrapped in quotes so was treated as a string instead of the number expected by code), however the error was a generic conversion error, which made troubleshooting difficult.

In case someone else encounters this issue, I'm leaving the "bug details" below.

Original "bug report" below

I want to report a bug:

--dry-run flag gives the "Indexing Complete" status but actual build fails with error: Error: no implicit conversion of String into Integer

What is the current behavior?

Aftger running the command bundle exec jekyll algolia I get the following output:

Configuration file: E:/Documentation/jekyll-deployment-scripts/jekyll-layout/_config.yml
Processing site...                                                               

Progress: |====================================================================|

Progress: |====================================================================|
Settings are already up to date.                                                 
Getting list of existing records                                                 
Updating records in index stg_help...                                            
Records to delete: 655                                                           
Records to add: 1406                                                             
jekyll 3.7.4 | Error:  no implicit conversion of String into Integer

To troubleshoot, I used the --dry-run flag (bundle exec jekyll algolia --dry-run) which displays "Indexing complete"

Configuration file: E:/Documentation/jekyll-deployment-scripts/jekyll-layout/_config.yml
Processing site...                                                               

Progress: |====================================================================|

Progress: |====================================================================|
Settings are already up to date.                                                 
Getting list of existing records                                                 
Updating records in index stg_help...                                            
Records to delete: 655                                                           
Records to add: 1406                                                             
✔ Indexing complete

To troubleshoot further I used the solution mentioned here: https://github.com/algolia/jekyll-algolia/issues/22#issuecomment-353566802

Using the json data file generated by the plugin linked above, I was successfully able to manually upload the whole data set in one go - I assumed that something about the data was off but there were no error messages when I submitted via the "manual upload" option on the web.

At this point, the value of the plugin (auto-updating the right records) is lost to me until I can figure out what setting, frontmatter, or other thing is causing the issue. Is there something I should look for in the content? (e.g. if my frontmatter has numeric properties, is that causing the issue?).

What is your expected behavior?

I expect either: 1) the --dry-run option should produce similar results to the live build. 2) a meaningful error message pointing to what data, line of json, or file caused the failure to upload.

Ruby version used:

This issue is consistent on two different platforms building the same content/config files (one's a build server - linux, one's my desktop - windows 10). Here are both ruby versions

windows: ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]

linux: ruby 2.5.1p57 (2018-03-29 revision 63029 [x86_64-linux-gnu]

Jekyll version used:

windows: jekyll 3.7.4

linux: jekyll 3.8.5

Cause/Resolution

The issue was due to the setting indexing_batch_size in quotes in _config.yml

Broken:

algolia:
  application_id: "XKCD797" # from account
  search_only_api_key: "00000000000000000000000000000000" # from account
  index_name: "my_index" # from account
  indexing_batch_size: "500" #BROKEN LINE IS HERE
  nodes_to_index: 'p,li,blockquote,dd'
  files_to_exclude: []

Working:

algolia:
  application_id: "XKCD797" # from account
  search_only_api_key: "00000000000000000000000000000000" # from account
  index_name: "my_index" # from account
  indexing_batch_size: 500  #FIXED LINE IS HERE
  nodes_to_index: 'p,li,blockquote,dd'
  files_to_exclude: []
Haroenv commented 3 years ago

Ah I guess this is because the dry run doesn't actually index, and thus doesn't use that part of the configuration. We'd love a PR where the types of the remaining unused settings are tested during dry run too