[PR #18854] [MERGED] Fixes #18782: Misconfigured ObjectListWidgets now degrade gracefully #15456

Closed
opened 2025-12-30 00:22:02 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18854
Author: @jnovinger
Created: 3/10/2025
Status: Merged
Merged: 3/18/2025
Merged by: @bctiemann

Base: mainHead: 18782-dashboard-broken-on-notification-list-widget


📝 Commits (2)

  • 528248b Fixes #18782: properly check if htmx_url is None
  • 76c3c61 Adds validation for ObjectListWidget.ConfigForm.model field

📊 Changes

2 files changed (+82 additions, -1 deletions)

View changed files

📝 netbox/extras/dashboard/widgets.py (+34 -1)
netbox/extras/tests/test_dashboard.py (+48 -0)

📄 Description

Fixes: #18782

This PR does two things to address this bug:

  • Updated the check before htmx_url has query params added so that we don't try to add them to None. This has the effect of properly triggering the branch in the template that indicates this widget can not be displayed.
  • It also adds validation for ObjectListWidget.ConfigForm.model via a clean_model method that checks to make sure that a model is supported by ObjectListWidget at the time of creation. This results in the following error for the user:
    image

I'm open to adjust that error message as needed.

I also played around with disabling unsupported object choices, but ended up not including those in the PR. Will add a screenshot if anyone is interested in seeing them.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/18854 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 3/10/2025 **Status:** ✅ Merged **Merged:** 3/18/2025 **Merged by:** [@bctiemann](https://github.com/bctiemann) **Base:** `main` ← **Head:** `18782-dashboard-broken-on-notification-list-widget` --- ### 📝 Commits (2) - [`528248b`](https://github.com/netbox-community/netbox/commit/528248b560db3aeba7a300bb34ccf6cf43384210) Fixes #18782: properly check if htmx_url is None - [`76c3c61`](https://github.com/netbox-community/netbox/commit/76c3c613a927965244ec8d123f557c9d1f7b3fd6) Adds validation for ObjectListWidget.ConfigForm.model field ### 📊 Changes **2 files changed** (+82 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/dashboard/widgets.py` (+34 -1) ➕ `netbox/extras/tests/test_dashboard.py` (+48 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #18782 This PR does two things to address this bug: - Updated the check before `htmx_url` has query params added so that we don't try to add them to `None`. This has the effect of properly triggering the branch in the template that indicates this widget can not be displayed. - It also adds validation for `ObjectListWidget.ConfigForm.model` via a `clean_model` method that checks to make sure that a model is supported by `ObjectListWidget` at the time of creation. This results in the following error for the user: ![image](https://github.com/user-attachments/assets/6396ca59-712b-489a-a8d5-918a87ef0cae) I'm open to adjust that error message as needed. I also played around with disabling unsupported object choices, but ended up not including those in the PR. Will add a screenshot if anyone is interested in seeing them. <!-- Please include a summary of the proposed changes below. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:22:02 +01:00
adam closed this issue 2025-12-30 00:22:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15456