sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.1k stars 1.27k forks source link

Code Insights: duplicate back slashes in search query #60890

Open vovakulikov opened 6 months ago

vovakulikov commented 6 months ago

Original slack thread

Created insight has double (additional) backslashes in the data points query URL. For instance, if you create insight with the following query select:file patterntype:regexp file:\.php content:class\s(.*)\s*extends\s*ModelRepo\s*\{

and after this click on some point on this insight on the insight dashboard you will see that you will be redirected to the search page which has repo:.* after:<some-date> before:<some-date>type:diff select:file file:\.php content:/class\\s(.*)\\s*extends\\s*ModelRepo\\s*\\{/

Note double backslashes in the query. This behaviour is expected based on code (because we had a problem with backslashes before with native input, but since we've migrated to the code mirror search box for insight query we probably should remove this logic about double slashes here, which may introduce this problem)

vovakulikov commented 6 months ago

@chwarwick it looks like we also add some additional backslashes on the backend as well.

The first picture is a response after creating an insight mutation with a newly created query (there is one additional backslash but I think it comes from the frontend so backend here is ok)

Screenshot 2024-03-06 at 11 30 54

But in this picture when we fetch insight on the dashboard with generated on the backend URLs for points there are some additional backslashes which come from the backend (also note that there are so additional slashes at the end and in the beginning in the content: filter which fails the search I think)

Screenshot 2024-03-06 at 11 30 29