Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Cody context: handle empty queries#60106

Merged
jtibshirani merged 1 commit into
mainfrom
jtibs/cody-context
Feb 2, 2024
Merged

Cody context: handle empty queries#60106
jtibshirani merged 1 commit into
mainfrom
jtibs/cody-context

Conversation

@jtibshirani

Copy link
Copy Markdown
Contributor

If a cody context query contains only stopwords, then query processing returns
a list of empty terms, causing a panic. Now, we just return an empty query
which matches no files.

Fixes #60090

Test plan

Added new unit test

@jtibshirani jtibshirani requested review from a team and chwarwick February 2, 2024 18:06
@cla-bot cla-bot Bot added the cla-signed label Feb 2, 2024
}

q, err := transformBasicQuery(plan[0])
basicQuery := plan[0].ToParseTree()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't necessary, just a refactor to remove a function layer

@chwarwick chwarwick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, this makes sense to me.

@jtibshirani jtibshirani merged commit 060d10d into main Feb 2, 2024
@jtibshirani jtibshirani deleted the jtibs/cody-context branch February 2, 2024 18:31
sourcegraph-release-bot pushed a commit that referenced this pull request Feb 2, 2024
If a cody context query contains only stopwords, then query processing returns
a list of empty terms, causing a panic. Now, we just return an empty query
which matches no files.

(cherry picked from commit 060d10d)
keegancsmith pushed a commit that referenced this pull request Feb 5, 2024
Cody context: handle empty queries (#60106)

If a cody context query contains only stopwords, then query processing returns
a list of empty terms, causing a panic. Now, we just return an empty query
which matches no files.

(cherry picked from commit 060d10d)

Co-authored-by: Julie Tibshirani <julietibs@apache.org>
jtibshirani added a commit that referenced this pull request Apr 12, 2024
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.
jtibshirani added a commit that referenced this pull request Apr 19, 2024
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.
keegancsmith pushed a commit that referenced this pull request Apr 21, 2024
…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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic during Cody remote context api

2 participants