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

Issue:
Further explicit field references found
<!--
    Before opening a new issue, please search through the existing issues to
    see if your topic has already been addressed. Note that you may need to
    remove the "is:open" filter from the search bar to include closed issues.

    Check the appropriate type for your issue below by placing an x between the
    brackets. If none of the below apply, please raise your issue for
    discussion on our mailing list:

        https://groups.google.com/forum/#!forum/netbox-discuss

    Please note that issues which do not fall under any of the below categories
    will be closed.
--->
### Issue type
[ ] Feature request <!-- Requesting the implementation of a new feature -->
[x] Bug report      <!-- Reporting unexpected or erroneous behavior -->
[ ] Documentation   <!-- Proposing a modification to the documentation -->

<!--
    Please describe the environment in which you are running NetBox. (Be sure
    to verify that you are running the latest stable release of NetBox before
    submitting a bug report.)
-->
### Environment
* Python version:  3.5.4
* NetBox version:  develop
<!--
    BUG REPORTS must include:
        * A list of the steps needed to reproduce the bug
        * A description of the expected behavior
        * Any relevant error messages (screenshots may also help)

    FEATURE REQUESTS must include:
        * A detailed description of the proposed functionality
        * A use case for the new feature
        * A rough description of any necessary changes to the database schema
        * Any relevant third-party libraries which would be needed
-->
### Description
Right now, the partial (included) consoleport.html template uses an explicit reference to the `name` field for display. This is also done by the `__str__()` class method of `ConsoleServerPort`, which is used in other locations (specifically, `dcim/console_connections_list.html`). Changing this here as well would assure consistency if the `__str__()` method is ever changed.
This builds on Issue #1651 
This change does not require any changes to the database schema, only a minor modification of the template.


Discussion:

Resolving patch:
diff --git a/netbox/secrets/models.py b/netbox/secrets/models.py
--- a/netbox/secrets/models.py
+++ b/netbox/secrets/models.py
@@ -286,6 +286,9 @@ def __init__(self, *args, **kwargs):
         super(Secret, self).__init__(*args, **kwargs)
 
     def __str__(self):
+        if self.role and self.device and self.name:
+            return '{} for {} ({})'.format(self.role, self.device, self.name)
+        # Return role and device if no name is set
         if self.role and self.device:
             return '{} for {}'.format(self.role, self.device)
         return 'Secret'


Test patch:
Repository: netbox-community/netbox

Issue:
Exporting racks to a file netbox_racks.csv, missing "serial" field.
### Issue type
[ ] Feature request <!-- Requesting the implementation of a new feature -->
[x] Bug report      <!-- Reporting unexpected or erroneous behavior -->
[ ] Documentation   <!-- Proposing a modification to the documentation -->

### Environment
* Python version:  2.7.5
* NetBox version:  2.2.1

### Description
i do export racks to file netbox_racks.csv
i do import and get error "Row 1: Expected 11 columns but found 10"
Found out that there is not enough one comma or not enough field "series"
When exporting racks to a file netbox_racks.csv, the **serial** field is not unloaded!!!


Discussion:

Resolving patch:
diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py
--- a/netbox/dcim/models.py
+++ b/netbox/dcim/models.py
@@ -296,6 +296,7 @@ def to_csv(self):
             self.tenant.name if self.tenant else None,
             self.role.name if self.role else None,
             self.get_type_display() if self.type else None,
+            self.serial,
             self.width,
             self.u_height,
             self.desc_units,


Test patch:
Repository: netbox-community/netbox

Issue:
Changing any 802.1Q Tagged VLANs causes an error
### Issue type
[X] Bug report      <!-- Unexpected or erroneous behavior -->

### Environment
* Python version:  3.6
* NetBox version:  2.3.0

### Description
After assigned VLANs to the `Tagged VLANs` on an interface and then attempting to change them causes an error to occur.

This is what you see when attempting to edit a previously creating set of tagged VLANs:
![image](https://user-images.githubusercontent.com/7783306/36810720-cbf60338-1c88-11e8-8ffd-14b915f30ea5.png)

Then, no matter what you do (remove one, re-select the same ones, remove them all), you get the following result:
![image](https://user-images.githubusercontent.com/7783306/36810796-0b6631b4-1c89-11e8-9677-1b88c5e0f4aa.png)



Discussion:

Resolving patch:
diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py
--- a/netbox/dcim/forms.py
+++ b/netbox/dcim/forms.py
@@ -1728,10 +1728,10 @@ def __init__(self, *args, **kwargs):
             self.fields['site'].initial = None
 
         # Limit the initial vlan choices
-        if self.is_bound:
+        if self.is_bound and self.data.get('vlan_group') and self.data.get('site'):
             filter_dict = {
-                'group_id': self.data.get('vlan_group') or None,
-                'site_id': self.data.get('site') or None,
+                'group_id': self.data.get('vlan_group'),
+                'site_id': self.data.get('site'),
             }
         elif self.initial.get('untagged_vlan'):
             filter_dict = {
@@ -1854,10 +1854,10 @@ def __init__(self, *args, **kwargs):
             self.fields['site'].initial = None
 
         # Limit the initial vlan choices
-        if self.is_bound:
+        if self.is_bound and self.data.get('vlan_group') and self.data.get('site'):
             filter_dict = {
-                'group_id': self.data.get('vlan_group') or None,
-                'site_id': self.data.get('site') or None,
+                'group_id': self.data.get('vlan_group'),
+                'site_id': self.data.get('site'),
             }
         elif self.initial.get('untagged_vlan'):
             filter_dict = {
@@ -1968,10 +1968,10 @@ def __init__(self, *args, **kwargs):
             self.fields['site'].queryset = Site.objects.none()
             self.fields['site'].initial = None
 
-        if self.is_bound:
+        if self.is_bound and self.data.get('vlan_group') and self.data.get('site'):
             filter_dict = {
-                'group_id': self.data.get('vlan_group') or None,
-                'site_id': self.data.get('site') or None,
+                'group_id': self.data.get('vlan_group'),
+                'site_id': self.data.get('site'),
             }
         else:
             filter_dict = {


Test patch:
Repository: netbox-community/netbox

Issue:
PUTs to Site Endpoint Requires Value for time_zone
<!--
    Before opening a new issue, please search through the existing issues to
    see if your topic has already been addressed. Note that you may need to
    remove the "is:open" filter from the search bar to include closed issues.

    Check the appropriate type for your issue below by placing an x between the
    brackets. For assistance with installation issues, or for any other issues
    other than those listed below, please raise your topic for discussion on
    our mailing list:

        https://groups.google.com/forum/#!forum/netbox-discuss

    Please note that issues which do not fall under any of the below categories
    will be closed. Due to an excessive backlog of feature requests, we are
    not currently accepting any proposals which extend NetBox's feature scope.

    Do not prepend any sort of tag to your issue's title. An administrator will
    review your issue and assign labels as appropriate.
--->
### Issue type
[ ] Feature request <!-- An enhancement of existing functionality -->
[X] Bug report      <!-- Unexpected or erroneous behavior -->
[ ] Documentation   <!-- A modification to the documentation -->

<!--
    Please describe the environment in which you are running NetBox. (Be sure
    to verify that you are running the latest stable release of NetBox before
    submitting a bug report.) If you are submitting a bug report and have made
    any changes to the code base, please first validate that your bug can be
    recreated while running an official release.
-->
### Environment
* Python version:  2.6.7
* NetBox version:  2.4-dev, but includes previous versions as well.

<!--
    BUG REPORTS must include:
        * A list of the steps needed for someone else to reproduce the bug
        * A description of the expected and observed behavior
        * Any relevant error messages (screenshots may also help)

    FEATURE REQUESTS must include:
        * A detailed description of the proposed functionality
        * A use case for the new feature
        * A rough description of any necessary changes to the database schema
        * Any relevant third-party libraries which would be needed
-->
### Description
More details over at digitalocean/pynetbox#59, but when the `time_zone` field is present and null we get an error saying it can't be null. Omitting the field doesn't return an error.


Discussion:

Resolving patch:
diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py
--- a/netbox/dcim/api/serializers.py
+++ b/netbox/dcim/api/serializers.py
@@ -80,7 +80,7 @@ class Meta:
 
 
 class WritableSiteSerializer(CustomFieldModelSerializer):
-    time_zone = TimeZoneField(required=False)
+    time_zone = TimeZoneField(required=False, allow_null=True)
 
     class Meta:
         model = Site


Test patch:
Repository: netbox-community/netbox

Issue:
OpenAPI showing 'basic' auth as option in securityDefinitions, should indicate use of Authorization header

### Issue type
[ ] Feature request <!-- An enhancement of existing functionality -->
[X] Bug report      <!-- Unexpected or erroneous behavior -->
[ ] Documentation   <!-- A modification to the documentation -->

### Environment
* Python version:  2.7
* NetBox version:  2.2.8


### Description

    * A list of the steps needed for someone else to reproduce the bug

1. get the openapi spec; for example, running a laptop instance, this URL would be: "http://0.0.0.0:32768/api/docs/?format=openapi". or you could use use curl or wget.

2.  at the very bottom, you will see "securityDefinitions" indicating basic auth.  basic auth is not supported in Netbox 2.2.8.

![2018-01-19_09-05-41](https://user-images.githubusercontent.com/2607956/35154423-3a9f0308-fcf8-11e7-9721-06e2f586362b.png)

        * A description of the expected and observed behavior

Here is an example of a system that uses request headers to store a token.  In this example, the header key is called "AUTHTOKEN".  For Netbox, this would be "Authorization", as documented [on the read-the-docs site.](https://netbox.readthedocs.io/en/latest/api/authentication)

![2018-01-19_09-10-24](https://user-images.githubusercontent.com/2607956/35154633-ee16c448-fcf8-11e7-8c75-c06c8c75bd5b.png)

        * Any relevant error messages (screenshots may also help)




Discussion:

Resolving patch:
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
--- a/netbox/netbox/settings.py
+++ b/netbox/netbox/settings.py
@@ -269,6 +269,13 @@
         'drf_yasg.inspectors.DjangoRestResponsePagination',
         'drf_yasg.inspectors.CoreAPICompatInspector',
     ],
+    'SECURITY_DEFINITIONS': {
+        'Bearer': {
+            'type': 'apiKey',
+            'name': 'Authorization',
+            'in': 'header',
+        }
+    },
     'VALIDATOR_URL': None,
 }
 


Test patch:
Repository: netbox-community/netbox

Issue:
Admin section issue
Hi!

<!--
    NOTE: This form is only for reproducible bugs. If you need assistance with
    NetBox installation, or if you have a general question, DO NOT open an
    issue. Instead, post to our mailing list:

        https://groups.google.com/forum/#!forum/netbox-discuss

    Please describe the environment in which you are running NetBox. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report.
-->
### Environment
* Python version:  Python 3.6.5
* NetBox version:  2.4.4 (moved from different server from version: 2.3.1)

<!--
    Describe in detail the steps that someone else can take to reproduce this
    bug using the current stable release of NetBox (or the current beta release
    where applicable).
-->
### Steps to Reproduce
The page https://netbox.domain.local/admin/ shows error:

**<class 'django.template.exceptions.TemplateDoesNotExist'>
django_rq/index.html**

<!-- What did you expect to happen? -->
### Expected Behavior
Get control panel

<!-- What happened instead? -->
### Observed Behavior
-

Thank you.


Discussion:
Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using the template provided [here](https://raw.githubusercontent.com/digitalocean/netbox/develop/.github/ISSUE_TEMPLATE.md). For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss).
Hello,

@jeremystretch 
we are also facing this issue. The problem is with having django_rq installed but webhooks disabled. This happens when using the Docker container from Nine.ch. In this container the `django_rq` is always installed, but you can still disable the webhooks backend. 

So when webhooks are disabled in the `settings.py` you have these lines (from 161):
```
# Only load django-rq if the webhook backend is enabled
if WEBHOOKS_ENABLED:
    INSTALLED_APPS.append('django_rq')
```

And in the `netbox/admin.py` you have this (from line 25):
```
# Modify the template to include an RQ link if django_rq is installed (see RQ_SHOW_ADMIN_LINK)
try:
    import django_rq
    admin_site.index_template = 'django_rq/index.html'
except ImportError:
    pass
```

I think a good fix for this would be to check in `admin.py` if the setting WEBHOOKS_ENABLED is true.

Kind regards
Tobias



Resolving patch:
diff --git a/netbox/netbox/admin.py b/netbox/netbox/admin.py
--- a/netbox/netbox/admin.py
+++ b/netbox/netbox/admin.py
@@ -23,8 +23,9 @@ class NetBoxAdminSite(AdminSite):
 admin_site.register(Tag, TagAdmin)
 
 # Modify the template to include an RQ link if django_rq is installed (see RQ_SHOW_ADMIN_LINK)
-try:
-    import django_rq
-    admin_site.index_template = 'django_rq/index.html'
-except ImportError:
-    pass
+if settings.WEBHOOKS_ENABLED:
+    try:
+        import django_rq
+        admin_site.index_template = 'django_rq/index.html'
+    except ImportError:
+        pass


Test patch:
Repository: netbox-community/netbox

Issue:
/api/dcim/interfaces?form_factor=0 (Virtual Interface) returns 0 results
### Environment
* Python version:  Python 3.4
* NetBox version:  2.4.8

### Steps to Reproduce
* Create a virtual interface (form_factor=0)
* Create a LAG interface
* Create a Physical 10GBE Interface (form_factor=1000)
* Run an API query against /api/dcim/interfaces?form_factor=0
   Result will be a count: 0
* Run an API query against /api/dcim/interfaces?form_factor=200
   Result will be a count of at least 1 (depends on environment)

<!-- What did you expect to happen? -->
### Expected Behavior
* API will return virtual interfaces for form_factor=0
* API will return LAG interfaces for form_factor=200
* API will return 1000GBE interfaces for form_factor=1000

<!-- What happened instead? -->
### Observed Behavior
* API does not return interfaces for form_factor=0
* API returns interfaces for form_factor=200
* API returns interfaces for form_factor=1000


Discussion:
I believe this is strictly related to form_factor=0 only, however I don't have time to investigate further today.  I did test this on a clean netbox 2.4.8 as well.
Appears to be related to the fact that 0 is treated as a null value.

To fix:

`    form_factor = django_filters.MultipleChoiceFilter(
        choices=IFACE_FF_CHOICES,
        null_value=None
    )
`

Resolving patch:
diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py
--- a/netbox/dcim/filters.py
+++ b/netbox/dcim/filters.py
@@ -13,7 +13,7 @@
 from virtualization.models import Cluster
 from .constants import (
     DEVICE_STATUS_CHOICES, IFACE_FF_LAG, NONCONNECTABLE_IFACE_TYPES, SITE_STATUS_CHOICES, VIRTUAL_IFACE_TYPES,
-    WIRELESS_IFACE_TYPES,
+    WIRELESS_IFACE_TYPES, IFACE_FF_CHOICES,
 )
 from .models import (
     ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
@@ -652,10 +652,14 @@ class InterfaceFilter(django_filters.FilterSet):
         method='filter_vlan',
         label='Assigned VID'
     )
+    form_factor = django_filters.MultipleChoiceFilter(
+        choices=IFACE_FF_CHOICES,
+        null_value=None
+    )
 
     class Meta:
         model = Interface
-        fields = ['name', 'form_factor', 'enabled', 'mtu', 'mgmt_only']
+        fields = ['name', 'enabled', 'mtu', 'mgmt_only']
 
     def filter_device(self, queryset, name, value):
         try:


Test patch:
Repository: netbox-community/netbox

Issue:
Cable Length under "Cables" concats length with the length_type id instead of name
### Environment
* Python version:  3.6
* NetBox version:  2.5

### Steps to Reproduce

* Create a cable connection with length and length_type specified (Ex. 6 "Inches"
* View connection in Devices->Cables

### Expected Behavior

Cable length defined as 6 Inches

### Observed Behavior

Cable length is defined as 62000


Discussion:
Working on a PR for this issue now.

Resolving patch:
diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py
--- a/netbox/dcim/tables.py
+++ b/netbox/dcim/tables.py
@@ -179,7 +179,7 @@
 """
 
 CABLE_LENGTH = """
-{% if record.length %}{{ record.length }}{{ record.length_unit }}{% else %}&mdash;{% endif %}
+{% if record.length %}{{ record.length }}{{ record.get_length_unit_display }}{% else %}&mdash;{% endif %}
 """
 
 


Test patch:
Repository: netbox-community/netbox

Issue:
Add "White" as a cable color
### Environment
* Python version:  3.6
* NetBox version:  2.5.1

### Proposed Functionality

Add color white to the cable colors.

Optionally add:

* ~~slate~~(Dark Grey works, almost identical color)
* rose
* ~~violet~~ (Fuschia works, almost identical color)
* aqua

### Use Case

These fiber strand colors are missing

### Database Changes

None

### External Dependencies

None


Discussion:

Resolving patch:
diff --git a/netbox/utilities/constants.py b/netbox/utilities/constants.py
--- a/netbox/utilities/constants.py
+++ b/netbox/utilities/constants.py
@@ -2,6 +2,7 @@
     ('aa1409', 'Dark red'),
     ('f44336', 'Red'),
     ('e91e63', 'Pink'),
+    ('ffe4e1', 'Rose'),
     ('ff66ff', 'Fuschia'),
     ('9c27b0', 'Purple'),
     ('673ab7', 'Dark purple'),
@@ -10,6 +11,7 @@
     ('03a9f4', 'Light blue'),
     ('00bcd4', 'Cyan'),
     ('009688', 'Teal'),
+    ('00ffff', 'Aqua'),
     ('2f6a31', 'Dark green'),
     ('4caf50', 'Green'),
     ('8bc34a', 'Light green'),
@@ -23,4 +25,5 @@
     ('9e9e9e', 'Grey'),
     ('607d8b', 'Dark grey'),
     ('111111', 'Black'),
+    ('ffffff', 'White'),
 )


Test patch:
Repository: netbox-community/netbox

Issue:
Search for Cable Labels on Mainpage Search
### Environment
* Python version:  3.6.6
* NetBox version:  2.5.2

### Proposed Functionality
Please add the possibility to search for "Cable Labels" in the Search-Field on the Top of the Mainpage. 

### Use Case
A real cable is labeled with "c1234" and a user wants to find the Termination A and B in netbox. At the moment (v2.5.2) the search shows "No results found".

### Database Changes
No

### External Dependencies
No


Discussion:

Resolving patch:
diff --git a/netbox/netbox/forms.py b/netbox/netbox/forms.py
--- a/netbox/netbox/forms.py
+++ b/netbox/netbox/forms.py
@@ -15,6 +15,7 @@
         ('devicetype', 'Device types'),
         ('device', 'Devices'),
         ('virtualchassis', 'Virtual Chassis'),
+        ('cable', 'Cables'),
     )),
     ('IPAM', (
         ('vrf', 'VRFs'),
diff --git a/netbox/netbox/views.py b/netbox/netbox/views.py
--- a/netbox/netbox/views.py
+++ b/netbox/netbox/views.py
@@ -11,13 +11,13 @@
 from circuits.models import Circuit, Provider
 from circuits.tables import CircuitTable, ProviderTable
 from dcim.filters import (
-    DeviceFilter, DeviceTypeFilter, RackFilter, RackGroupFilter, SiteFilter, VirtualChassisFilter
+    DeviceFilter, DeviceTypeFilter, RackFilter, RackGroupFilter, SiteFilter, VirtualChassisFilter, CableFilter
 )
 from dcim.models import (
-    Cable, ConsolePort, Device, DeviceType, Interface, PowerPort, Rack, RackGroup, Site, VirtualChassis
+    Cable, ConsolePort, Device, DeviceType, Interface, PowerPort, Rack, RackGroup, Site, VirtualChassis, Cable
 )
 from dcim.tables import (
-    DeviceDetailTable, DeviceTypeTable, RackTable, RackGroupTable, SiteTable, VirtualChassisTable
+    DeviceDetailTable, DeviceTypeTable, RackTable, RackGroupTable, SiteTable, VirtualChassisTable, CableTable
 )
 from extras.models import ObjectChange, ReportResult, TopologyMap
 from ipam.filters import AggregateFilter, IPAddressFilter, PrefixFilter, VLANFilter, VRFFilter
@@ -88,6 +88,12 @@
         'table': VirtualChassisTable,
         'url': 'dcim:virtualchassis_list',
     }),
+    ('cable', {
+        'queryset': Cable.objects.all(),
+        'filter': CableFilter,
+        'table': CableTable,
+        'url': 'dcim:cable_list',
+    }),
     # IPAM
     ('vrf', {
         'queryset': VRF.objects.select_related('tenant'),


Test patch:
Repository: netbox-community/netbox

Issue:
Add LC/APC, SC/APC and LSH/APC port types
### Environment
* Python version:  <!-- Example: 3.5.4 --> 3.5.3
* NetBox version:  <!-- Example: 2.3.6 --> 2.5.6

### Proposed Functionality

Add LC/APC, SC/APC and LSH/APC port types.

### Use Case

We need to track LC PC/APC and SC PC/APC port type on patch panel.

<!--
    Note any changes to the database schema necessary to support the new
    feature. For example, does the proposal require adding a new model or
    field? (Not all new features require database changes.)
--->
### Database Changes

None.
<!--
    List any new dependencies on external libraries or services that this new
    feature would introduce. For example, does the proposal require the
    installation of a new Python package? (Not all new features introduce new
    dependencies.)
-->
### External Dependencies

None.


Discussion:

Resolving patch:
diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py
--- a/netbox/dcim/constants.py
+++ b/netbox/dcim/constants.py
@@ -270,11 +270,14 @@
 PORT_TYPE_110_PUNCH = 1100
 PORT_TYPE_ST = 2000
 PORT_TYPE_SC = 2100
+PORT_TYPE_SC_APC = 2110
 PORT_TYPE_FC = 2200
 PORT_TYPE_LC = 2300
+PORT_TYPE_LC_APC = 2310
 PORT_TYPE_MTRJ = 2400
 PORT_TYPE_MPO = 2500
 PORT_TYPE_LSH = 2600
+PORT_TYPE_LSH_APC = 2610
 PORT_TYPE_CHOICES = [
     [
         'Copper',
@@ -288,10 +291,13 @@
         [
             [PORT_TYPE_FC, 'FC'],
             [PORT_TYPE_LC, 'LC'],
+            [PORT_TYPE_LC_APC, 'LC/APC'],
             [PORT_TYPE_LSH, 'LSH'],
+            [PORT_TYPE_LSH_APC, 'LSH/APC'],
             [PORT_TYPE_MPO, 'MPO'],
             [PORT_TYPE_MTRJ, 'MTRJ'],
             [PORT_TYPE_SC, 'SC'],
+            [PORT_TYPE_SC_APC, 'SC/APC'],
             [PORT_TYPE_ST, 'ST'],
         ]
     ]


Test patch: