Advanced Query Processing Architecture - #7
Conversation
…7534) * Loki query splitting: interpolate queries before execution * Update tests * Prettier * shardQuerySplitting: remove unnecessary call
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| .filter((query) => query.expr) | ||
| .filter((query) => !query.hide); | ||
| .filter((query) => !query.hide) | ||
| .map((query) => datasource.applyTemplateVariables(query, request.scopedVars, request.filters)); |
There was a problem hiding this comment.
Shard path applies templates twice
Medium Severity
runShardSplitQuery() now applies applyTemplateVariables() before delegating to runSplitQuery(), which also applies applyTemplateVariables(). This double interpolation makes shard-split requests non-idempotent, especially for request.filters, where ad hoc filters can be appended repeatedly to already-interpolated expr values.
Additional Locations (1)
| .filter((query) => query.expr) | ||
| .filter((query) => !query.hide); | ||
| .filter((query) => !query.hide) | ||
| .map((query) => datasource.applyTemplateVariables(query, request.scopedVars, request.filters)); |
There was a problem hiding this comment.
Empty interpolated expressions are still executed
Medium Severity
The new interpolation flow filters query.expr before calling applyTemplateVariables(). If interpolation resolves an expression to an empty string, that target is no longer removed and can continue through split execution, leading to invalid empty expr queries being scheduled.
Additional Locations (1)
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions! |


Test 4nn
Summary by CodeRabbit
Bug Fixes
$__autoand time intervals are now properly substituted before query execution on a per-query basis, ensuring accurate query processing and results.Tests
✏️ Tip: You can customize this high-level summary in your review settings.
nn---n*Replicated from [ai-code-review-evaluation/grafana-coderabbit#4](https://github.com/ai-code-review-evaluation/grafana-coderabbit/pull/4)*Note
Medium Risk
Touches core Loki query execution paths for time- and shard-splitting; incorrect interpolation could subtly change queries sent to Loki, but changes are small and covered by added/updated tests.
Overview
Ensures Loki query splitting paths interpolate template variables before executing sub-requests by applying
datasource.applyTemplateVariables()to each target up front (includingstep), instead of relying on later/batch interpolation.Updates shard-splitting to use the same per-query interpolation approach and adjusts tests accordingly, adding coverage for
$__auto/$stepreplacement and verifying interpolatedexpr/stepvalues are whatrunQueryreceives.Written by Cursor Bugbot for commit 3ba2457. Configure here.