Commit 6c3e1dc
markup_parser: skip parsing HTML content when it is empty (#161)
## Issue
This PR resolves the following CI error.
```
Error:
FullTextSearch::BatchRunnerSynchronizeTest#test_archived_changeset:
RuntimeError: input string cannot be empty
plugins/full_text_search/lib/full_text_search/markup_parser.rb:20:in `parse'
plugins/full_text_search/lib/full_text_search/issue_mapper.rb:25:in `upsert_fts_target'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:129:in `block (2 levels) in synchronize_fts_targets_internal'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:335:in `each'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:335:in `each'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:335:in `iterate'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:121:in `block in synchronize_fts_targets_internal'
plugins/full_text_search/lib/full_text_search/resolver.rb:43:in `each'
plugins/full_text_search/lib/full_text_search/resolver.rb:43:in `each'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:116:in `synchronize_fts_targets_internal'
plugins/full_text_search/lib/full_text_search/batch_runner.rb:12:in `synchronize'
plugins/full_text_search/test/unit/full_text_search/batch_runner_synchronize_test.rb:34:in `setup'
bin/rails test plugins/full_text_search/test/unit/full_text_search/batch_runner_synchronize_test.rb:219
```
## Cause
The error occurs because Nokogiri's behavior for handling an empty
string changed in version 1.17.0.
- Before 1.17.0: `Nokogiri::HTML::SAX::Parser#parse` returned `nil` when
passed an empty string.
- After 1.17.0: `Nokogiri::HTML::SAX::Parser#parse` raises a
`RuntimeError` when passed an empty string.
Refer to the following Nokogiri commit for details:
sparklemotion/nokogiri@35596e7
## Solution
Skip parsing the HTML content when it is empty by adding a presence
check.
---------
Co-authored-by: Sutou Kouhei <[email protected]>1 parent d1b063d commit 6c3e1dc
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
0 commit comments