-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboards: Skip inherited object variable names #79567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jarben 😄 , great attempt to fix this issue. Because our variable system is complex, I would like to gain more context of the original escalation, would you mind sharing a dashboard example where the escalation issue can be reproduced?
So far, I tested your branch locally, taking the use case from the other related issue: #79212 (using $toString
in a query variable), and I still see the problem.
toStringStillTriggersJsError.mp4
I believe the reason is the getVariableName
from inspect/utils
is not the same function we are using when we are interpolating variables(getTemplateSrv().replace).
Hi @Alexa Vargas, thanks for looking at this! The issue can be reproduced here. You can add yourself to the org by adding your email to staff membership here. |
Good point @axelavargas , this would prevent the error to appear: Although I wonder if we want the variable to not show at all here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jarben 😄 , Thanks for granting me access to the original issue.
I have tested on my local machine a dashboard with Mongo DB and variables and works as expected, the errors disappeared 🥳 .
VariablesMongoWorkingAgain.mp4
Also Issues 67342 and 79212 are still unresolved, and I am afraid the change you suggested in the getVariabledAtIndex
will not work as should be. We will prevent showing the error, but the expected behavior should be to do the query by taking the $toString
as a normal string. After researching, I found we don't support escaping variable expressions in the query, check this issue #40603 .
I think your PR will only fix the issue from the escalation 🙌🏾 . However, we will need to tackle the other ones in another PR (A bit challenging to be honest with the current variable system)
What is this feature?
This PR fixes an issue where variables containing inherited object property names fail with TypeError:
T[Q].add is not a function
here. This issue has been reported in this escalation.This is because
if (varName! in panelsByVar) {
returnstrue
for any variable name that matches inherited prop names.We can potentially use if
(panelsByVar.hasOwnProperty(varName))
; however, this would add variables such astoString
and would fail anyway as reported here and[here](https://github.com/grafana/grafana/issues/67342)
.Which issue(s) does this PR fix?:
Fixes https://github.com/grafana/support-escalations/issues/8743
Also relates to: https://community.grafana.com/t/error-updating-options-t-e-add-is-not-a-function/71728/7
Special notes for your reviewer:
Please check that: