-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Context: avoid panic on stopwords query #62026
Conversation
@@ -70,3 +74,18 @@ func (j *searchJob) MapChildren(fn job.MapFunc) job.Job { | |||
cp.child = job.Map(j.child, fn) | |||
return &cp | |||
} | |||
|
|||
func newNoopJob() *noopJob { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have NewNoopJob
in jobutil
, but using it would introduce an import cycle. I opted to create a new private one since it's really simple, and it's nice to keep this Cody context logic very separate.
@@ -1137,6 +1137,52 @@ func testSearchClient(t *testing.T, client searchClient) { | |||
} | |||
}) | |||
|
|||
t.Run("Cody context search", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not have guessed to look here for end to end tests. Glad I learned this 😀
Thanks for the speedy review! I'm going to merge + backport as I want to make the patch release Monday. |
The backport to
To backport this PR manually, you can either: Via the sg toolUse the sg backport -r 5.3.9104 -p 62026 Via your terminalTo backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.3.9104 5.3.9104
# Navigate to the new working tree
cd .worktrees/backport-5.3.9104
# Create a new branch
git switch --create backport-62026-to-5.3.9104
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 fe5853195ee5c421ad8de16579652fd2854c1022
# Push it to GitHub
git push --set-upstream origin backport-62026-to-5.3.9104
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.3.9104 If you encouter conflict, first resolve the conflict and stage all files, then run the commands below: git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-62026-to-5.3.9104
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.3.9104
Once the pull request has been created, please ensure the following:
|
In #61848, we tried to fix an issue when the query contained only stopwords and we interpreted this as "match all files". Unfortunately this fix introduced a panic by returning a nil search job, which is not allowed by the our job framework. Now, we return a `noopJob` which returns no results. This is the same approach we use when an AND/ OR query has no operands.
…62055) * Context: return no results for stopwords query (#61848) In #60106, we fixed a bug where the context search threw an error when the query was composed entirely of stopwords. However, the queries were still returning results (based on filename match). This means that for a stopwords-only query like "what's going on?" we return a fairly random set of files, which confuses the LLM. Now we make sure to return an empty search, which returns no results. * Context: avoid panic on stopwords query (#62026) In #61848, we tried to fix an issue when the query contained only stopwords and we interpreted this as "match all files". Unfortunately this fix introduced a panic by returning a nil search job, which is not allowed by the our job framework. Now, we return a `noopJob` which returns no results. This is the same approach we use when an AND/ OR query has no operands.
In #61848, we tried to fix an issue when the query contained only stopwords and
we interpreted this as "match all files". Unfortunately this fix introduced a panic by
returning a nil search job, which is not allowed by the our job framework.
Now, we return a
noopJob
which returns no results. This is the same approachwe use when an AND/ OR query has no operands.
Test plan
My testing was clearly lacking in the previous fix!! This time, I've added new
end-to-end GraphQL tests using
patterntype:codycontext
. Also tested manuallyand checked there are no errors or panics in logs.