You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On v1.20.5, if String() method of a prometheus.Desc returned from NewInvalidDesc called, it will cause a nil pointer derefence, which will result in an incorrectly formatted string
Hey there, @SealOfTime! I'm here to assist you with any bugs, questions, or contributions while we wait for a human maintainer. Let's squash those bugs together! 🤖
To prevent a nil pointer dereference in the String() method of a prometheus.Desc when NewInvalidDesc creates a Desc with variableLabels set to nil, you can add a nil check for d.variableLabels before accessing its fields. Here's how you can modify the String() method:
This modification ensures that the code checks if d.variableLabels is nil before attempting to access its names field, thus preventing a nil pointer dereference [1].
On v1.20.5, if String() method of a prometheus.Desc returned from NewInvalidDesc called, it will cause a nil pointer derefence, which will result in an incorrectly formatted string
NewInvalidDesc will create a Desc with
variableLabels
equal to nil, therefore accessing its fieldnames
will cause a nil-pointer dereference.The result is:
descriptor %!s(PANIC=String method: runtime error: invalid memory address or nil pointer dereference) is invalid: test
The consequence of that is an unpleasant error message in prometheus.Register
The text was updated successfully, but these errors were encountered: