Fix autoresearch crash on zero-result search queries#54
Merged
Conversation
A search query returning 0 rows made .validate_autoresearch_search_results and autoresearch_run_searches assign a length-1 value (date, source, query, angle) onto a 0-row data.frame, erroring with 'replacement has 1 row, data has 0'. Build all columns at full length before filtering empty URLs, which also keeps date/source aligned when the URL filter drops rows. Add a regression test for the empty-result and mixed-URL paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
autoresearch()crashes mid-run when any search query returns zero results. Tagging the result rows withdate,source,query, andangleassigns a length-1 value onto a 0-row data.frame:Hit in practice when the query planner emits a
site:github.com/OWNER/REPOpath-scoped query that the search backend can't satisfy (returns 0 rows).Fix
.validate_autoresearch_search_results()now builds every column (title,url,snippet,date,source) at fullnrow(x)length, then filters empty URLs once. This fixes the 0-row crash and a latent bug where the old code assignedx$date(full length) onto an already-url-filteredout(shorter), misaligning rows.autoresearch_run_searches()usesrep.int(..., nrow(df))to tagquery/angle, matching the safe pattern already used for theroundcolumn.Test
Regression test in
test_autoresearch.Rcovering the zero-result validator path, the mixed-URL filter alignment, and the full search loop with an empty backend. Full suite green (128 tests).