Skip to content

insights: just-in-time capture group pattern insights incorrectly handle multiple repositories, returning incorrect partial results

Created by: Joelkw

If you create a just-in-time capture group insight like the following:

image

The results returned are incorrect and undercount the true results.

What happens is:

  1. In reverse-listed order in the UI form (so starting at the end of the list first), we return results for capture groups for just the last-matching repository. This means in the above example:
    1. the sourcegraph/about repo has 193 matches for code\sinsights – as shown in the tooltip for 193, but it misses 482 results from sourcegraph/sourcegraph
    2. Because there are no results for code\sinside in /handbook, it correctly reports the 1 result from /sourcegraph – it skips the "last repo" because it has no results and uses the "first repo with results" (in this case, the only other repo.

What should happen is:

  1. We correctly sum the results across all repos, for each capture group. So in this case code\sinsights should have 675 matches (for `ghts).