-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fail gracefully if Custom Link URL does not expand #3461
Comments
Completely agree with this FR. If an object doesn't have a field or attribute used in a custom link, it shouldn't cause the whole page to fail. I was surprised by this when I tried to manually create a new device and then after I did, I received an error stating that an attribute didn't exist. Immediately I went to the open / closed issues and found this one and #3299 and the "work around" did solve the problem. My opinion is that it should fail gracefully instead of the failing hard as it currently does, especially for something as common as |
Handling the exception gracefully is easy, but reporting the failure to the user needs more thought. Exceptions can occur while rendering either the text or URL of grouped or non-grouped links, and the exception message needs to be conveyed in an obvious yet non-intrusive manner. |
I believe that putting the text of the exception (without backtrace) in the "title" attribute means it will be displayed as a tooltip in most browsers. It seems modern browsers support "title" atttribute on <option> elements too, so that should deal with grouped links. I just tested it:
In Chrome 76, this works as expected: hover over the disabled 'baz' option and you see the message. For anyone who doesn't have a compatible browser, but still wants to know why a particular selection is disabled, they can always inspect the HTML to read the title attribute. |
Environment
Proposed Functionality
At the moment, if you define a Custom Link but there is a template expansion failure in the link URL, Netbox raises a full-blown exception instead of displaying the object you requested. Users tend to confuse this with a bug in Netbox (e.g. #3304, forum)
I propose instead: if a template error occurs during expansion of the URL in a Custom Link, display the button greyed out. Preferably include the exception text as a tooltip.
Note: it's also possible that a template error occurs during expansion of the Text in a Custom Link. In that case, I think it's reasonable to continue to raise an exception, but an alternative would be to log the error and suppress the button, as if the text were blank.
Use Case
obj.primary_ip4.address.ip
without having to worry whether the device has that field defined or notDatabase Changes
None
External Dependencies
None
The text was updated successfully, but these errors were encountered: