-
Notifications
You must be signed in to change notification settings - Fork 19
Fix: Handle undefined value in performance attribute Jira-OPG-492 #1048
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
Conversation
|
@sbernabe1 @dino2gnt @marshallmassengill Thanks for finding this issue. Could someone confirm what value for Is it If it is something else, but it's not a Also if this worked before, but now the value is always In any case we should not need to |
|
@synqotik, thanks for the detailed questions! I've done some more testing and have a few updates on what's going on. First, to answer your question: the value of propertyValue being passed is indeed undefined when the TypeError first occurs. Your check of if (!propertyValue) is an attempt to handle that initial error.
However, I found that even with that check, I was still getting a TypeError on a subsequent call, even though the propertyValue was an OnmsNode object. It seems that the object is a complex type that the function isn't expecting.
You were right that we shouldn't have to stringify/parse the object. But in this case, it was the only way to successfully "sanitize" the object by creating a shallow copy containing only the data the function needed. This allows the rest of the function to execute without error and properly process the node's properties. The current code in the pull request now includes both the if (!propertyValue) check and the JSON.parse(JSON.stringify(...)) fix, which addresses the root cause of the TypeError. |
|
@sbernabe1 thanks for the info! The issue might be that in Try this out. First, exit if Also in the code you display, part of Grafana's code, |
|
@synqotik, the following is the output when trying to test the updated code provided: Error's from "rpm run watch":
|
|
@synqotik, I've made some updates to fix the error while still using the suggestions you recommended. Looks like this works, no need for JSON implementation:
|
|
@sbernabe1 ahh ok, try this instead, it's just a Typescript issue, need to cast if (!propertyValue) {
return
}
const propertyValueAny = propertyValue as any
const node = {
id: String(propertyValueAny.id ?? ''),
label: String(propertyValueAny.label ?? '')
} as PerformanceAttributeItemStateHopefully this works! |
|
@synqotik, this works! Code:
Result:
|
|
Nice! Looks good. I think it was just that the |
|
@sbernabe1 you can go ahead and make that change and I'll approve. |
|
|
@synqotik, thank you for validating this with me! I really appreciate the support :) I have gone ahead and updated the changes. |
synqotik
left a comment
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.
LGTM!
|
I went ahead and merged this |









Description:
This pull request fixes a TypeError that occurred when processing data from the Performance data source. The previous code was attempting to access a property on an undefined variable, which would cause the plugin to fail.
The fix ensures the variable is correctly checked for a value before being used, preventing the error.
Release-9.x
Please Review:
@synqotik
@marshallmassengill