diff --git a/lib/error_handler.rb b/lib/error_handler.rb index 61cf450..6286b14 100644 --- a/lib/error_handler.rb +++ b/lib/error_handler.rb @@ -82,6 +82,12 @@ class AlgoliaSearchErrorHandler return 'check_key_acl_to_tmp_index' end + # Pushed record is above the 10KB limit + if error['http_error'] == 400 && + error['json']['message'] =~ /^Record is too big/ + return 'record_too_big' + end + false end end diff --git a/spec/error_handler_spec.rb b/spec/error_handler_spec.rb index a4790d4..ad9ca40 100644 --- a/spec/error_handler_spec.rb +++ b/spec/error_handler_spec.rb @@ -121,6 +121,23 @@ describe(AlgoliaSearchErrorHandler) do expect(actual).to eq('check_key_acl_to_tmp_index') end + it 'should warn about big records' do + # Given + parsed = { + 'http_error' => 400, + 'json' => { + 'message' => 'Record is too big size=220062 bytes' + } + } + allow(@error_handler).to receive(:parse_algolia_error).and_return(parsed) + + # When + actual = @error_handler.readable_algolia_error('error') + + # Then + expect(actual).to eq('record_too_big') + end + it 'should return false if no nice message found' do # Given parsed = false diff --git a/txt/record_too_big b/txt/record_too_big new file mode 100644 index 0000000..43dc0ed --- /dev/null +++ b/txt/record_too_big @@ -0,0 +1,19 @@ +Algolia Error: Record too big + Records pushed to Algolia have a max possible size of 10KB. Records above this + limit will be rejected. + + You see this error because at least one of the records the plugin is trying to + push is above this limit. + + The plugin creates a record for each `
` paragraph of text found in your + pages. If one of them contains a huge chunk of text it may trigger this error. + + You can configure the CSS selector used to create records through the + `record_css_selector` option. The default is `p` (meaning all `
` + paragraphs). You can update this value to use a negation selector to exclude + some parts. + + For example `p:not(.do-not-index)` will only index paragraphs that do not have + the class `do-not-index`. + + See https://github.com/algolia/algoliasearch-jekyll for more information