Cloning boolean custom fields does not work if their value is False #10058

Closed
opened 2025-12-29 21:26:18 +01:00 by adam · 5 comments
Owner

Originally created by @peteeckel on GitHub (Aug 7, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.8

Python Version

3.11

Steps to Reproduce

  1. Create a custom field 'test' with type 'Boolean', 'Is clonable' checked for an arbitrary object type, say ipam.IPAddress
  2. Set the custom field to False for an arbitrary IPAddress object and click on 'Save'
  3. Click on 'Clone'

Expected Behavior

The cloned object has its 'test' CF set to False

Observed Behavior

The cloned object has its 'test' CF set to None

If you look at the parameters of the URL for the 'Clone' button, the relevant part is test=. This is identical whether the CF 'test' was False for the original object or if it was undefined.

This is particularly relevant for required fields, as it makes it necessary to set the field explicitly for cloned objects even if cloning the field was enabled.

Originally created by @peteeckel on GitHub (Aug 7, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.8 ### Python Version 3.11 ### Steps to Reproduce 1. Create a custom field 'test' with type 'Boolean', 'Is clonable' checked for an arbitrary object type, say `ipam.IPAddress` 2. Set the custom field to `False` for an arbitrary `IPAddress` object and click on 'Save' 3. Click on 'Clone' ### Expected Behavior The cloned object has its 'test' CF set to `False` ### Observed Behavior The cloned object has its 'test' CF set to `None` If you look at the parameters of the URL for the 'Clone' button, the relevant part is `test=`. This is identical whether the CF 'test' was `False` for the original object or if it was undefined. This is particularly relevant for required fields, as it makes it necessary to set the field explicitly for cloned objects even if cloning the field was enabled.
adam added the type: bugstatus: needs ownerpending closurenetboxseverity: low labels 2025-12-29 21:26:18 +01:00
adam closed this issue 2025-12-29 21:26:18 +01:00
Author
Owner

@peteeckel commented on GitHub (Aug 7, 2024):

I did not run the NetBox test suite yet, but there seems to be a trivial fix:

(netbox) [root@dns netbox]# git diff 
diff --git a/netbox/utilities/querydict.py b/netbox/utilities/querydict.py
index 78395758a..dbe2e4281 100644
--- a/netbox/utilities/querydict.py
+++ b/netbox/utilities/querydict.py
@@ -55,7 +55,7 @@ def prepare_cloned_fields(instance):
     for key, value in attrs.items():
         if type(value) in (list, tuple):
             params.extend([(key, v) for v in value])
-        elif value is not False and value is not None:
+        elif value is not None:
             params.append((key, value))
         else:
             params.append((key, ''))
@peteeckel commented on GitHub (Aug 7, 2024): I did not run the NetBox test suite yet, but there seems to be a trivial fix: ```python (netbox) [root@dns netbox]# git diff diff --git a/netbox/utilities/querydict.py b/netbox/utilities/querydict.py index 78395758a..dbe2e4281 100644 --- a/netbox/utilities/querydict.py +++ b/netbox/utilities/querydict.py @@ -55,7 +55,7 @@ def prepare_cloned_fields(instance): for key, value in attrs.items(): if type(value) in (list, tuple): params.extend([(key, v) for v in value]) - elif value is not False and value is not None: + elif value is not None: params.append((key, value)) else: params.append((key, '')) ```
Author
Owner

@arthanson commented on GitHub (Aug 9, 2024):

@peteeckel do you want to take this one?

@arthanson commented on GitHub (Aug 9, 2024): @peteeckel do you want to take this one?
Author
Owner

@peteeckel commented on GitHub (Aug 9, 2024):

@peteeckel do you want to take this one?

Sure, I'll be glad to.

@peteeckel commented on GitHub (Aug 9, 2024): > @peteeckel do you want to take this one? Sure, I'll be glad to.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 17, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 17, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jul 17, 2025):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jul 17, 2025): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10058