Benchmark: grafana PR 107534 - #14
celmis-codereviewer wants to merge 6 commits into
Conversation
celmis-codereviewer
left a comment
There was a problem hiding this comment.
💬 COMMENT — findings to consider
Full findings and scope are in the review summary comment on this pull request — one persistent comment, updated in place on every run.
| const queries = request.targets | ||
| .filter((query) => !query.hide) | ||
| .filter((query) => query.expr) | ||
| .map((query) => datasource.applyTemplateVariables(query, request.scopedVars, request.filters)); |
There was a problem hiding this comment.
Why: When request.targets contains a query with a template variable that evaluates to an empty string, filter((query) => query.expr) on line 299 evaluates to true before interpolation, causing the resulting query with an empty expr on line 300 to be included in queries instead of being filtered out.
🟡 Query expression filter runs before template variable interpolation
filter((query) => query.expr) is executed before datasource.applyTemplateVariables(...). If a target's expr contains a template variable (such as $variable) that interpolates to an empty string "", the filter evaluates to true on the un-interpolated string. applyTemplateVariables then replaces the variable with "", resulting in a query object with an empty expr being passed to partition and execution instead of being filtered out.
The same defect is at 2 locations: public/app/plugins/datasource/loki/querySplitting.ts:299, public/app/plugins/datasource/loki/shardQuerySplitting.ts:50.
| .map((query) => datasource.applyTemplateVariables(query, request.scopedVars, request.filters)); | |
| const queries = request.targets | |
| .filter((query) => !query.hide) | |
| .map((query) => datasource.applyTemplateVariables(query, request.scopedVars, request.filters)) | |
| .filter((query) => query.expr); |
agent: defect · rule: defect.logic-error · confidence: 0.85
🤖 Code Review for PR #14⚙ ADJUSTED — graph context partial (0 of 4 changed files): 4 of 4 changed files have no symbols in the index; 4 of them are not in that checkout at all (public/app/plugins/datasource/loki/querySplitting.test.ts, public/app/plugins/datasource/loki/querySplitting.ts, public/app/plugins/datasource/loki/shardQuerySplitting.test.ts, public/app/plugins/datasource/loki/shardQuerySplitting.ts) — this PR's base is older than the indexed revision, so those files were renamed or deleted before it and no re-index can bring them back; there is nothing to fix. 💬 COMMENT — findings to consider Findings
Scope
Performance
Powered by Code Analyzer · context: tree-sitter graph + structural, cve, contract, security, defect |
Benchmark reproduction of grafana#107534