insights: restrict capture group values to a max length
Created by: leonore
closes #29552 (closed).
We truncate capture group values to <= 100 characters for both just-in-time insights and insights ran over all repos for consistency, even though we only store captured values for insights ran over all repos.
Test plan
Added, and ran unit tests (with -count=20 for flakes).
On my local sourcegraph instance:
- Reduce the
capturedValueMaxLength
value to 10, for ease of search. - Started up sg locally.
- Created an insight, e.g.
patterntype:regexp compare (.*) lang:go
- for just-in-time
- for all repos
- Observed the insight was getting created, and was truncating the results.
- Check postgres for stored values:
SELECT capture FROM series_points ORDER BY time DESC LIMIT 10;
- also compared values for the query before/after change:
-
SELECT capture FROM series_points WHERE length(capture) > 20 ORDER BY time DESC
-> returned an example(v fileInfosByName)
- after truncation implementation,
SELECT capture FROM series_points WHERE capture LIKE '%v%' ORDER BY time DESC;
returned(v fileIn)
(N.B. This is 10 characters with the whitespace at the front, something we might want to consider)