Hi there 👋
| 🌥️ Tech |
🌤️ Feat |
| 1 high, 2 medium, 3 low |
1 mitigated |
The MR correctly moves query interpolation to the start of the query-splitting pipeline for both time-based and shard-based paths, using applyTemplateVariables instead of the previous per-step interpolation, which fixes variable resolution (e.g. $env) and aligns metric step grouping with the resolved step. However, the shard path now double-applies template variables/adhoc filters: applyTemplateVariables is invoked both in runShardSplitQuery and again inside runSplitQuery for each shard group, and since addAdHocFilters is not idempotent, adhoc filters are duplicated in the final selector. Tests also have gaps/misleading assertions: the $__auto test asserts a mock artifact rather than real applyTemplateVariables behavior, the shard test locks in the double-interpolation implementation detail, and fallback/coverage paths are untested. These issues should be addressed before merging.
These might need a close look
- 🔴 public/app/plugins/datasource/loki/shardQuerySplitting.ts (L52)
Adhoc filters are applied twice in the shard path. applyTemplateVariables is called here and again inside runSplitQuery (invoked for each shard group), and addAdHocFilters is not idempotent, so adhoc filters are duplicated in the final selector. Interpolate exactly once.
Worth checking
- 🟡 public/app/plugins/datasource/loki/querySplitting.test.ts (L88)
Test $__auto expectation does not reflect real applyTemplateVariables behavior: applyTemplateVariables leaves $__auto unresolved for backend interpolation, so the test asserts a mock artifact and gives false confidence. Use a genuinely frontend-resolved variable and assert $__auto/$__range remain unresolved.
- 🟡 public/app/plugins/datasource/loki/shardQuerySplitting.test.ts (L112)
Test asserts applyTemplateVariables called 5 times (double interpolation), locking in the double-application bug. Assert final expr/step and that filters are applied exactly once.
Small things (take or leave)
- 🔵 public/app/plugins/datasource/loki/querySplitting.test.ts (L75)
New test does not cover interpolation's interaction with grouping and non-splittable classification: does not verify interpolated step participates in metric grouping, that $__range queries remain non-splittable, or that interpolation happens before partitionTimeRange/direction classification.
- 🔵 public/app/plugins/datasource/loki/shardQuerySplitting.test.ts (L469)
Misleading comment says 'No more than 50% of the remaining shards' but constrainGroupSize uses 0.7 (70%) cap. Comments should say 70%.
- 🔵 public/app/plugins/datasource/loki/shardQuerySplitting.test.ts (L53)
Coverage gap: no-shard and fetch-error fallback paths are untested. Add test asserting a single unsharded runSplitQuery completes with LoadingState.Done.
✅ Feature-level checklist
Partially covered
- ⚠️ Interpolate queries at the start of the process (fixes #107530)
Interpolation is moved to the start via applyTemplateVariables, but in the shard path interpolation is applied a second time, causing adhoc filters to be duplicated. Tests also do not accurately assert interpolation of genuine frontend-resolved variables.
FriendlyReviewer found 0 of the 1 golden comment of this PR — recall 0%. The golden is a small test-setup detail:
applyTemplateVariablesis called withrequest.filtersas its third parameter, but the corresponding test setup never uses that parameter (querySplitting.test.ts). The review scrutinized the PR's tests — the$__autotest asserting a mock artifact, the shard test freezing the double interpolation, untested fallback paths — yet missed this specific unused argument.The score, however, understates what the review found. FriendlyReviewer identified a genuine functional bug that the dataset does not cover: in the shard path,
applyTemplateVariablesis invoked both inrunShardSplitQueryand again insiderunSplitQueryfor each shard group, and sinceaddAdHocFiltersis not idempotent, adhoc filters end up duplicated in the final selector (shardQuerySplitting.ts L52, flagged 🔴). That is a real regression in query results — arguably more consequential than the dataset's single test-setup comment — and it is unscored.This is the clearest case in the run of the recall metric not telling the whole story: the review's best finding is invisible to the score. The flip side is equally true: the only dataset-credited comment is a test-hygiene detail that the review missed despite deep test scrutiny, so the zero is also earned. Both facts matter when reading the result.
Overall: the review understood the PR's mechanics correctly and caught its most user-visible defect, but the scored outcome remains 0% — a reminder that recall measures overlap with a specific reference set, not the total value of a review.