internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: netbox-community/netbox

Issue:
Request to add SFP+ types
### NetBox version

v3.4.5

### Feature type

Change to existing functionality

### Proposed functionality

Netbox currently supports:

    # Fibrechannel
    TYPE_1GFC_SFP = '1gfc-sfp'
    TYPE_2GFC_SFP = '2gfc-sfp'
    TYPE_4GFC_SFP = '4gfc-sfp'
    TYPE_8GFC_SFP_PLUS = '8gfc-sfpp'
    TYPE_16GFC_SFP_PLUS = '16gfc-sfpp'
    TYPE_32GFC_SFP28 = '32gfc-sfp28'
    TYPE_64GFC_QSFP_PLUS = '64gfc-qsfpp'
    TYPE_128GFC_QSFP28 = '128gfc-qsfp28'

What we need to add:

    TYPE_32GFC_SFP_PLUS = '32gfc-sfpp’          => [Brocade 32Gb/s SWL SFP+ Product Brief](https://urldefense.com/v3/__https:/docs.broadcom.com/docs/GA-DS-2048__;!!BhdT!ls37dMy4pnF-6hdYjEYU8fb0n6iAjFY6b79usqjQOZ2rQE8wrRVNwh-m5e35xVboDcJ1jLAri-dA37NF2R1jRDFY$)
    TYPE_64GFC_SFP_PLUS = '64gfc-sfpp’          => [Brocade 32Gb/s SWL SFP+ Product Brief](https://urldefense.com/v3/__https:/docs.broadcom.com/docs/GA-DS-2048__;!!BhdT!ls37dMy4pnF-6hdYjEYU8fb0n6iAjFY6b79usqjQOZ2rQE8wrRVNwh-m5e35xVboDcJ1jLAri-dA37NF2R1jRDFY$)
    TYPE_64GFC_SFP_DD = '64gfc-sfpdd'            => [Brocade 64G SWL SFP-DD Product Brief](https://urldefense.com/v3/__https:/docs.broadcom.com/docs/SFP-DD-64G-SWL-PB__;!!BhdT!ls37dMy4pnF-6hdYjEYU8fb0n6iAjFY6b79usqjQOZ2rQE8wrRVNwh-m5e35xVboDcJ1jLAri-dA37NF2eSQwXt0$)



### Use case

We need to have above types added to Netbox as we are using them to build out DC. It will be usefull for the other users building the environment by Brocade vendor devices.

### Database changes

_No response_

### External dependencies

_No response_


Discussion:
if @jeremystretch approves I could do that
@apellini I have assigned this to you.
@jeremystretch I can do this

Resolving patch:
diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py
--- a/netbox/dcim/choices.py
+++ b/netbox/dcim/choices.py
@@ -889,7 +889,10 @@ class InterfaceTypeChoices(ChoiceSet):
     TYPE_8GFC_SFP_PLUS = '8gfc-sfpp'
     TYPE_16GFC_SFP_PLUS = '16gfc-sfpp'
     TYPE_32GFC_SFP28 = '32gfc-sfp28'
+    TYPE_32GFC_SFP_PLUS = '32gfc-sfpp'
     TYPE_64GFC_QSFP_PLUS = '64gfc-qsfpp'
+    TYPE_64GFC_SFP_DD = '64gfc-sfpdd'
+    TYPE_64GFC_SFP_PLUS = '64gfc-sfpp'
     TYPE_128GFC_QSFP28 = '128gfc-qsfp28'
 
     # InfiniBand
@@ -1058,7 +1061,10 @@ class InterfaceTypeChoices(ChoiceSet):
                 (TYPE_8GFC_SFP_PLUS, 'SFP+ (8GFC)'),
                 (TYPE_16GFC_SFP_PLUS, 'SFP+ (16GFC)'),
                 (TYPE_32GFC_SFP28, 'SFP28 (32GFC)'),
+                (TYPE_32GFC_SFP_PLUS, 'SFP+ (32GFC)'),
                 (TYPE_64GFC_QSFP_PLUS, 'QSFP+ (64GFC)'),
+                (TYPE_64GFC_SFP_DD, 'SFP-DD (64GFC)'),
+                (TYPE_64GFC_SFP_PLUS, 'SFP+ (64GFC)'),
                 (TYPE_128GFC_QSFP28, 'QSFP28 (128GFC)'),
             )
         ),


Test patch:
Repository: netbox-community/netbox

Issue:
The VirtualMachineType in GraphQL is missing the `contacts` property
### NetBox version

v3.7.3

### Feature type

Data model extension

### Proposed functionality

I propose that the `ContactMixin` class is added to the `VirtualMachineType` class in the GraphQL files. I was wondering where I could find it, as I could find the property in the `DeviceType` class. I have a pull request ready which I'd be happy to submit for review.

### Use case

It allows users to get information about contacts associated with virtual machine objects

### Database changes

None

### External dependencies

None


Discussion:
Sounds like a bug.
@jeremystretch I'd be happy to help. By applying the changes in https://github.com/klstilling/netbox/commit/e76b0184a7235209a36fe49e0d6a2c47043a2d57 the property becomes available in the GraphQL API. If there's anything I can do, just poke me.
This is blocked by #9856 as it is completely rewritten what is returned.

Resolving patch:
diff --git a/netbox/extras/graphql/mixins.py b/netbox/extras/graphql/mixins.py
--- a/netbox/extras/graphql/mixins.py
+++ b/netbox/extras/graphql/mixins.py
@@ -7,6 +7,7 @@
 __all__ = (
     'ChangelogMixin',
     'ConfigContextMixin',
+    'ContactsMixin',
     'CustomFieldsMixin',
     'ImageAttachmentsMixin',
     'JournalEntriesMixin',
diff --git a/netbox/virtualization/graphql/types.py b/netbox/virtualization/graphql/types.py
--- a/netbox/virtualization/graphql/types.py
+++ b/netbox/virtualization/graphql/types.py
@@ -1,5 +1,5 @@
 from dcim.graphql.types import ComponentObjectType
-from extras.graphql.mixins import ConfigContextMixin
+from extras.graphql.mixins import ConfigContextMixin, ContactsMixin
 from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
 from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType
 from virtualization import filtersets, models
@@ -38,7 +38,7 @@ class Meta:
         filterset_class = filtersets.ClusterTypeFilterSet
 
 
-class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
+class VirtualMachineType(ConfigContextMixin, ContactsMixin, NetBoxObjectType):
 
     class Meta:
         model = models.VirtualMachine


Test patch:
Repository: netbox-community/netbox

Issue:
Device Types "All Data (YAML)" export does not include Description
### Deployment Type

Self-hosted

### NetBox Version

v3.7.3

### Python Version

3.8

### Steps to Reproduce

1. Create Device Type with a description
2. Export Device Types with "All Data (YAML)" export
3. Examine export which does not include the Description field of the device type the set description that was set

Reproducible on demo.netbox.dev

### Expected Behavior

Expect the Description field to be present in export.

### Observed Behavior

No Description field is present in export.


Discussion:
Looks like the description field is missing from the `to_yaml()` method on the DeviceType model. It's probably worth a quick audit for missing fields in the method on other models too.
The `description` field is missing from ModuleType as well.

Resolving patch:
diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py
--- a/netbox/dcim/models/devices.py
+++ b/netbox/dcim/models/devices.py
@@ -229,15 +229,16 @@ def to_yaml(self):
             'manufacturer': self.manufacturer.name,
             'model': self.model,
             'slug': self.slug,
+            'description': self.description,
             'default_platform': self.default_platform.name if self.default_platform else None,
             'part_number': self.part_number,
             'u_height': float(self.u_height),
             'is_full_depth': self.is_full_depth,
             'subdevice_role': self.subdevice_role,
             'airflow': self.airflow,
-            'comments': self.comments,
             'weight': float(self.weight) if self.weight is not None else None,
             'weight_unit': self.weight_unit,
+            'comments': self.comments,
         }
 
         # Component templates
@@ -415,9 +416,10 @@ def to_yaml(self):
             'manufacturer': self.manufacturer.name,
             'model': self.model,
             'part_number': self.part_number,
-            'comments': self.comments,
+            'description': self.description,
             'weight': float(self.weight) if self.weight is not None else None,
             'weight_unit': self.weight_unit,
+            'comments': self.comments,
         }
 
         # Component templates


Test patch:
Repository: netbox-community/netbox

Issue:
Add Virtual Chassis Members to API Request
### NetBox version

3.3.10

### Feature type

Data model extension

### Proposed functionality

Add virtual chassis members to the API when getting the virtual chassis info.

### Use case

This would allow me to query all of the virtual-chassis information in one request. 

### Database changes

_No response_

### External dependencies

_No response_


Discussion:
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/develop/CONTRIBUTING.md).

Resolving patch:
diff --git a/netbox/dcim/api/serializers_/virtualchassis.py b/netbox/dcim/api/serializers_/virtualchassis.py
--- a/netbox/dcim/api/serializers_/virtualchassis.py
+++ b/netbox/dcim/api/serializers_/virtualchassis.py
@@ -12,6 +12,7 @@
 class VirtualChassisSerializer(NetBoxModelSerializer):
     url = serializers.HyperlinkedIdentityField(view_name='dcim-api:virtualchassis-detail')
     master = NestedDeviceSerializer(required=False, allow_null=True, default=None)
+    members = NestedDeviceSerializer(many=True, read_only=True)
 
     # Counter fields
     member_count = serializers.IntegerField(read_only=True)
@@ -20,6 +21,6 @@ class Meta:
         model = VirtualChassis
         fields = [
             'id', 'url', 'display', 'name', 'domain', 'master', 'description', 'comments', 'tags', 'custom_fields',
-            'created', 'last_updated', 'member_count',
+            'created', 'last_updated', 'member_count', 'members',
         ]
         brief_fields = ('id', 'url', 'display', 'name', 'master', 'description', 'member_count')
diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py
--- a/netbox/dcim/api/views.py
+++ b/netbox/dcim/api/views.py
@@ -511,7 +511,10 @@ class CableTerminationViewSet(NetBoxModelViewSet):
 #
 
 class VirtualChassisViewSet(NetBoxModelViewSet):
-    queryset = VirtualChassis.objects.all()
+    queryset = VirtualChassis.objects.prefetch_related(
+        # Prefetch related object for the display of unnamed devices
+        'master__virtual_chassis',
+    )
     serializer_class = serializers.VirtualChassisSerializer
     filterset_class = filtersets.VirtualChassisFilterSet
 


Test patch:
Repository: netbox-community/netbox

Issue:
Typo in Tag model
### Deployment Type

Self-hosted

### NetBox Version

v3.7.4

### Python Version

3.8

### Steps to Reproduce

Typo in help_text where "this" is mistakenly repeated.

https://github.com/netbox-community/netbox/blob/69c0aac1051015660133b2ae3c86607dabd8084b/netbox/extras/models/tags.py#L40

### Expected Behavior

The object type(s) to which this tag can be applied.

### Observed Behavior

The object type(s) to which this this tag can be applied.


Discussion:

Resolving patch:
diff --git a/netbox/extras/models/tags.py b/netbox/extras/models/tags.py
--- a/netbox/extras/models/tags.py
+++ b/netbox/extras/models/tags.py
@@ -37,7 +37,7 @@ class Tag(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel, TagBase):
         to='contenttypes.ContentType',
         related_name='+',
         blank=True,
-        help_text=_("The object type(s) to which this this tag can be applied.")
+        help_text=_("The object type(s) to which this tag can be applied.")
     )
 
     clone_fields = (


Test patch:
Repository: netbox-community/netbox

Issue:
Empty search entries are being created for device asset tags
### Deployment Type

NetBox Cloud

### NetBox Version

v3.7.4

### Python Version

3.11

### Steps to Reproduce

1. Create a new device and note its database ID
2. In the NetBox shell, inspect all search entries associated with it:

```python
ct = ContentType.objects.get_for_model(Device)
device_id = 107
entries = CachedValue.objects.filter(object_type=ct, object_id=device_id)
for entry in entries:
    print(f'{entry.field}: {entry.value}')
```

### Expected Behavior

Only fields which have a meaningful value set should have search entries created.

### Observed Behavior

After creating a device with a description, I see three entries for it:

```
asset_tag: None
name: device1
description: asdasdasd
```

The value of `asset_tag` is null.


Discussion:
This bug appears to affect any field which returns a null value (None).

Resolving patch:
diff --git a/netbox/netbox/search/__init__.py b/netbox/netbox/search/__init__.py
--- a/netbox/netbox/search/__init__.py
+++ b/netbox/netbox/search/__init__.py
@@ -59,9 +59,10 @@ def get_field_type(instance, field_name):
     @staticmethod
     def get_field_value(instance, field_name):
         """
-        Return the value of the specified model field as a string.
+        Return the value of the specified model field as a string (or None).
         """
-        return str(getattr(instance, field_name))
+        if value := getattr(instance, field_name):
+            return str(value)
 
     @classmethod
     def get_category(cls):


Test patch:
Repository: netbox-community/netbox

Issue:
Format default user preferences (and other) JSON when populating the config editor
### NetBox version

v3.7.0

### Feature type

Change to existing functionality

### Proposed functionality

When editing **Default user preferences** in Current Config - Edit, the JSON is shown just dumped, like this (very short example):

> {"tables": {"ASNTable": {"columns": ["asn", "tags"]}, "RackTable": {"columns": ["name", "site", "get_utilization", "get_power_utilization"]}}}

I propose that the JSON data would be formatted using the same formatter as in the Current Config screen (before editing, showing JSON nicely structured and indented) before showing it in the edit box, instead of just dumping the compressed JSON data there.

If there are other similar JSON-based configuration items, this same principle can probably be used in them all.

### Use case

When fine-tuning the typically very long JSON data in the config editor it is hard to locate and understand particular keys and values in the unformatted JSON dump. Formatting the JSON data nicely will help editing the data and preventing errors when modifying and saving the configuration.

Even if the editor shows the data structured and indented, it is nevertheless saved in the optimal compressed format, so there is no loss of efficiency in the database.

### Database changes

None

### External dependencies

None (`json` module from Python standard library can be used unless some other method is already preferred in NetBox)


Discussion:
I have tested code for this, so I'm willing to submit a PR if this FR is accepted.

Resolving patch:
diff --git a/netbox/core/forms/model_forms.py b/netbox/core/forms/model_forms.py
--- a/netbox/core/forms/model_forms.py
+++ b/netbox/core/forms/model_forms.py
@@ -3,6 +3,7 @@
 
 from django import forms
 from django.conf import settings
+from django.forms.fields import JSONField as _JSONField
 from django.utils.translation import gettext_lazy as _
 
 from core.forms.mixins import SyncedDataMixin
@@ -12,7 +13,7 @@
 from netbox.registry import registry
 from netbox.utils import get_data_backend_choices
 from utilities.forms import BootstrapMixin, get_field_value
-from utilities.forms.fields import CommentField
+from utilities.forms.fields import CommentField, JSONField
 from utilities.forms.widgets import HTMXSelect
 
 __all__ = (
@@ -132,6 +133,9 @@ def __new__(mcs, name, bases, attrs):
                 'help_text': param.description,
             }
             field_kwargs.update(**param.field_kwargs)
+            if param.field is _JSONField:
+                # Replace with our own JSONField to get pretty JSON in config editor
+                param.field = JSONField
             param_fields[param.name] = param.field(**field_kwargs)
         attrs.update(param_fields)
 


Test patch:
Repository: netbox-community/netbox

Issue:
Change "Interface" to "Tunnel interface" in tunnel termination form
### NetBox version

v3.7.0

### Feature type

Change to existing functionality

### Proposed functionality

I'm proposing changing the "**Interface**" field to "**Tunnel interface**" in the VPN tunnel termination form.

### Use case

The current terminology talking about "tunnel termination" and then asking for **interface** hints the user that this is the actual tunnel starting point (outside interface).

However, the real purpose of the field is to designate the **route-based tunnel interface** (inside interface), not the tunnel source/destination (outside) interface. This is somewhat confusing, especially when the next field is called "Outside IP" that definitely talks about the tunnel outside interface. (That's logical thinking in other cases for me at least: first you select interface, then you select the IP of that interface)

Example issue of the current confusion is #14681.

Renaming the interface field to "**Tunnel interface**" would guide the user to use the tunnel (inside) interface, not the outside interface.


### Database changes

Not sure if this naming change should involve changing some internal structures as well

### External dependencies

_No response_


Discussion:
If I've understood your proposal correctly, this change can be made without model changes, just a wording change to the tunnel termination creation form. Go ahead with a PR if you agree.

Resolving patch:
diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py
--- a/netbox/vpn/forms/model_forms.py
+++ b/netbox/vpn/forms/model_forms.py
@@ -91,7 +91,7 @@ class TunnelCreateForm(TunnelForm):
     termination1_termination = DynamicModelChoiceField(
         queryset=Interface.objects.all(),
         required=False,
-        label=_('Interface'),
+        label=_('Tunnel interface'),
         query_params={
             'device_id': '$termination1_parent',
         }
@@ -126,7 +126,7 @@ class TunnelCreateForm(TunnelForm):
     termination2_termination = DynamicModelChoiceField(
         queryset=Interface.objects.all(),
         required=False,
-        label=_('Interface'),
+        label=_('Tunnel interface'),
         query_params={
             'device_id': '$termination2_parent',
         }
@@ -238,7 +238,7 @@ class TunnelTerminationForm(NetBoxModelForm):
     )
     termination = DynamicModelChoiceField(
         queryset=Interface.objects.all(),
-        label=_('Interface'),
+        label=_('Tunnel interface'),
         query_params={
             'device_id': '$parent',
         }
diff --git a/netbox/vpn/tables/tunnels.py b/netbox/vpn/tables/tunnels.py
--- a/netbox/vpn/tables/tunnels.py
+++ b/netbox/vpn/tables/tunnels.py
@@ -88,7 +88,7 @@ class TunnelTerminationTable(TenancyColumnsMixin, NetBoxTable):
         verbose_name=_('Host')
     )
     termination = tables.Column(
-        verbose_name=_('Interface'),
+        verbose_name=_('Tunnel interface'),
         linkify=True
     )
     ip_addresses = tables.ManyToManyColumn(


Test patch:
Repository: netbox-community/netbox

Issue:
Add possibility to clone API tokens
### NetBox version

v3.7.1

### Feature type

New functionality

### Proposed functionality

I'm proposing adding a **Clone** function in API tokens, the similar way the Clone button works for example in prefixes.

Desired functionality:
- Open an API token
- Click Clone (the new button proposed here)
- The resulted form is basically the same as in adding a new token, but:
    - User, Write enabled, Expires, Description and Allowed IPs fields are prepopulated with the previous values (user can change them if needed)
    - Key field is a new randomly generated key, just like when creating a new API token



### Use case

The use case is rotating API tokens. Currently it is not possible to edit the Key field of an API token, so you have to use the Add button when rotating the tokens, and this requires you to manually enter the identical/relevant User, Expires, Description and Allowed IPs fields to match the previous API token, most often using two browser windows/tabs.

Adding the cloning possibility removes the need to copy+paste the fields manually to the new token.

### Database changes

None

### External dependencies

None


Discussion:
Thanks for raising this feature request, and thanks in particular for the clear and concise write-up.

If you are interested in doing the work to implement your idea, please let us know and we will assign the issue to you. Otherwise another developer with spare capacity can pick it up any time.
Yes, please, assign this to me, I'll have a go on this.

Resolving patch:
diff --git a/netbox/users/models.py b/netbox/users/models.py
--- a/netbox/users/models.py
+++ b/netbox/users/models.py
@@ -17,6 +17,7 @@
 from core.models import ContentType
 from ipam.fields import IPNetworkField
 from netbox.config import get_config
+from netbox.models.features import CloningMixin
 from utilities.querysets import RestrictedQuerySet
 from utilities.utils import flatten_dict
 from .constants import *
@@ -234,7 +235,7 @@ def create_userconfig(instance, created, raw=False, **kwargs):
 # REST API
 #
 
-class Token(models.Model):
+class Token(CloningMixin, models.Model):
     """
     An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens.
     It also supports setting an expiration time and toggling write ability.
@@ -285,6 +286,10 @@ class Token(models.Model):
         ),
     )
 
+    clone_fields = (
+        'user', 'expires', 'write_enabled', 'description', 'allowed_ips',
+    )
+
     objects = RestrictedQuerySet.as_manager()
 
     class Meta:


Test patch:
Repository: netbox-community/netbox

Issue:
Links within embedded tables do not load when HTMX is enabled
### Deployment Type

Self-hosted

### NetBox Version

v4.0-beta1

### Python Version

3.10

### Steps to Reproduce

1. Go to user preferences and enable HTMX Navigation
2. Go to a site and attach an image
3. Click on the parent of that image, which should be the site itself
4. Opens the card `Site` and `Custom Fields` within `Images`

### Expected Behavior

It opens the site in the same tab like every other link.

### Observed Behavior

![error1](https://github.com/netbox-community/netbox/assets/41152397/3c85c7bb-d8c2-4324-a394-81e101828ad5)



Discussion:
And in addition, the edit button does not work. The dropdown menu is also displayed in the card body instead of beyond the edge of the card.

![image](https://github.com/netbox-community/netbox/assets/41152397/039d5320-7cf9-40a8-9fb2-2ae712a32d71)

> The dropdown menu is also displayed in the card body instead of beyond the edge of the card.

Tagging #15536 as the same fix is likely needed here.
Changed the issue title as this seems to impact all embedded tables, not just image attachments.

Resolving patch:
diff --git a/netbox/netbox/views/generic/object_views.py b/netbox/netbox/views/generic/object_views.py
--- a/netbox/netbox/views/generic/object_views.py
+++ b/netbox/netbox/views/generic/object_views.py
@@ -381,7 +381,7 @@ def get(self, request, *args, **kwargs):
             return self._handle_protected_objects(obj, e.restricted_objects, request, e)
 
         # If this is an HTMX request, return only the rendered deletion form as modal content
-        if request.htmx:
+        if htmx_partial(request):
             viewname = get_viewname(self.queryset.model, action='delete')
             form_url = reverse(viewname, kwargs={'pk': obj.pk})
             return render(request, 'htmx/delete_form.html', {
diff --git a/netbox/utilities/htmx.py b/netbox/utilities/htmx.py
--- a/netbox/utilities/htmx.py
+++ b/netbox/utilities/htmx.py
@@ -10,4 +10,4 @@ def htmx_partial(request):
     Determines whether to render partial (versus complete) HTML content
     in response to an HTMX request, based on the target element.
     """
-    return request.htmx and request.htmx.target != PAGE_CONTAINER_ID
+    return request.htmx and request.htmx.target and request.htmx.target != PAGE_CONTAINER_ID
diff --git a/netbox/utilities/templatetags/builtins/tags.py b/netbox/utilities/templatetags/builtins/tags.py
--- a/netbox/utilities/templatetags/builtins/tags.py
+++ b/netbox/utilities/templatetags/builtins/tags.py
@@ -8,6 +8,7 @@
     'checkmark',
     'copy_content',
     'customfield_value',
+    'htmx_table',
     'formaction',
     'tag',
 )


Test patch: