dosubot[bot] commented on issue #8829:
URL: 
https://github.com/apache/incubator-devlake/issues/8829#issuecomment-4218044932

   <!-- Greeting -->
   Hi @mcseemz! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
incubator-devlake team.
   
   <!-- Answer -->
   This looks like a valid bug. The core issue is that Grafana's multi-value 
variable substitution for `$team` (and `$users`) injects raw values into SQL 
`IN` clauses without quoting, which breaks when IDs are non-numeric strings.
   
   I confirmed the problem exists in multiple dashboards:
   
   - **WorkLogs.json** — the `$users` variable query uses `team_users.team_id 
in ($team)` without quoting 
[[1]](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/WorkLogs.json#L1440),
 and panel queries similarly use `ua.user_id in ($users)` unquoted 
[[2]](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/WorkLogs.json#L219).
   - **DORAByTeam.json** — has at least 9 instances of `t.name in (${team})` 
without quoting across all DORA metric queries 
[[3]](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/DORAByTeam.json#L209).
   - **EngineeringThroughputAndCycleTimeTeamView.json** — uses `team_id in 
(${team1})` without quoting 
[[4]](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/EngineeringThroughputAndCycleTimeTeamView.json#L213).
   
   Grafana's MySQL datasource *does* support quoting for multi-value string 
variables — you need to wrap the variable with single quotes and use the 
`Include All` option correctly. The typical fix is to change queries from:
   
   ```sql
   WHERE team_users.team_id in ($team)
   ```
   
   to:
   
   ```sql
   WHERE team_users.team_id in (${team:singlequote})
   ```
   
   Or alternatively, the Grafana variable's "Custom all value" and formatting 
can handle this via the `${variable:sqlstring}` or `${variable:singlequote}` 
syntax depending on the Grafana version.
   
   Additionally, as you noted, the `--` delimiter used in the concat-regex 
pattern (`concat(name, '--', id)` with regex `/^(?<text>.*)--(?<value>.*)$/`) 
will break if team or user IDs contain `--` 
[[5]](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/WorkLogs.json#L1447-L1449).
 Using a less common delimiter or documenting this restriction would help.
   
   No existing PRs or prior conversations addressing this were found, so this 
appears to be a new report.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention 
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=too_verbose)
 | [Hallucination](https://
 
app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other#message_id=ebaf7d1c-bf36-489a-8e26-7f77f83afbda&feedback_type=other)</sup>
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/b4e8e847-d479-4541-83a8-d88d83fea5c9/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20looks%20like%20a%20valid%20bug.%20The%20core%20issue%20is%20that%20Grafana%27s%20multi-value%20variable%20substitution%20for%20%60%24team%60%20%28and%20%60%24users%60%29%20injects%20raw%20values%20into%20SQL%20%60IN%60%20clauses%20without%20quoting%2C%20which%20breaks%20when%20IDs%20are%20non-numeric%20strings.%0A%0AI%20confirmed%20the%20problem%20exists%20in%20multiple%20dashboards%3A%0A%0A-%20%2A%2AWorkLogs.json%2A%2A%20%E2%80%94%20the%20%60%24users%60%20variable%20query%20uses%20%60team_users.team_id%20in%20%28%24team%29%60%20without%20quoting%20%5B%5B1%5D%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dash
 
boards/WorkLogs.json%23L1440%29%2C%20and%20panel%20queries%20similarly%20use%20%60ua.user_id%20in%20%28%24users%29%60%20unquoted%20%5B%5B2%5D%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/WorkLogs.json%23L219%29.%0A-%20%2A%2ADORAByTeam.json%2A%2A%20%E2%80%94%20has%20at%20least%209%20instances%20of%20%60t.name%20in%20%28%24%7Bteam%7D%29%60%20without%20quoting%20across%20all%20DORA%20metric%20queries%20%5B%5B3%5D%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/DORAByTeam.json%23L209%29.%0A-%20%2A%2AEngineeringThroughputAndCycleTimeTeamView.json%2A%2A%20%E2%80%94%20uses%20%60team_id%20in%20%28%24%7Bteam1%7D%29%60%20without%20quoting%20%5B%5B4%5D%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/EngineeringThroughputAndCycleTimeTeamView.json%23L213%29.%0A%0AGrafana%27s%20MySQL%20datasou
 
rce%20%2Adoes%2A%20support%20quoting%20for%20multi-value%20string%20variables%20%E2%80%94%20you%20need%20to%20wrap%20the%20variable%20with%20single%20quotes%20and%20use%20the%20%60Include%20All%60%20option%20correctly.%20The%20typical%20fix%20is%20to%20change%20queries%20from%3A%0A%0A%60%60%60sql%0AWHERE%20team_users.team_id%20in%20%28%24team%29%0A%60%60%60%0A%0Ato%3A%0A%0A%60%60%60sql%0AWHERE%20team_users.team_id%20in%20%28%24%7Bteam%3Asinglequote%7D%29%0A%60%60%60%0A%0AOr%20alternatively%2C%20the%20Grafana%20variable%27s%20%22Custom%20all%20value%22%20and%20formatting%20can%20handle%20this%20via%20the%20%60%24%7Bvariable%3Asqlstring%7D%60%20or%20%60%24%7Bvariable%3Asinglequote%7D%60%20syntax%20depending%20on%20the%20Grafana%20version.%0A%0AAdditionally%2C%20as%20you%20noted%2C%20the%20%60--%60%20delimiter%20used%20in%20the%20concat-regex%20pattern%20%28%60concat%28name%2C%20%27--%27%2C%20id%29%60%20with%20regex%20%60/%5E%28%3F%3Ctext%3E.%2A%29--%28%3F%3Cvalue%3E.%2A%29%24/%60%29%2
 
0will%20break%20if%20team%20or%20user%20IDs%20contain%20%60--%60%20%5B%5B5%5D%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/grafana/dashboards/WorkLogs.json%23L1447-L1449%29.%20Using%20a%20less%20common%20delimiter%20or%20documenting%20this%20restriction%20would%20help.%0A%0ANo%20existing%20PRs%20or%20prior%20conversations%20addressing%20this%20were%20found%2C%20so%20this%20appears%20to%20be%20a%20new%20report.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-devlake/issues/8829)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to