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

Issue:
Import Objects UI `All or nothing import` field should be set as True by default.
<!--
    NOTE: This template is for use by maintainers only. Please do not submit
    an issue using this template unless you have been specifically asked to
    do so.
-->
### Proposed Changes
![Screenshot 2024-03-11 at 5 09 19 PM](https://github.com/nautobot/nautobot/assets/94907097/04953180-6489-4948-9497-dfbf74b505d7)

As a Nautobot user, I want the "all or nothing" option to be the default when I do a CSV import, so that I am not surprised by partial data when there is an error, since this is the common case.

The `All or nothing` import field in the Import Objects UI should be ticked by default.

Change the check box label to: "Rollback changes on Failure"

Make the help text:
"If an error is encountered when processing any row of data, rollback the entire import such that no data is imported."

<!-- Provide justification for the proposed change(s). -->
### Justification
For concestiency with older versions of nautobot


Discussion:

Resolving patch:
diff --git a/nautobot/core/jobs/__init__.py b/nautobot/core/jobs/__init__.py
--- a/nautobot/core/jobs/__init__.py
+++ b/nautobot/core/jobs/__init__.py
@@ -201,10 +201,10 @@ class ImportObjects(Job):
     csv_data = TextVar(label="CSV Data", required=False)
     csv_file = FileVar(label="CSV File", required=False)
     roll_back_if_error = BooleanVar(
-        label="All or nothing import",
+        label="Rollback Changes on Failure",
         required=False,
-        default=False,
-        description="Enable so that if any error occurs while importing, even successfully imported objects will be discarded. Disable if a partial import is acceptable.",
+        default=True,
+        description="If an error is encountered when processing any row of data, rollback the entire import such that no data is imported.",
     )
 
     template_name = "system_jobs/import_objects.html"


Test patch:
Repository: nautobot/nautobot

Issue:
Duplicated location link in VLAN_LINK
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable):
* Python version:
* Database platform, version:
* Middleware(s):

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
Location is duplicated in `VLAN_LINK` in `ipam.tables.py` :

```
...
{% url 'ipam:vlan_add' %}\
?vid={{ record.vid }}&vlan_group={{ vlan_group.pk }}\
{% if vlan_group.location %}&location={{ vlan_group.location.pk }}{% endif %}\
{% if vlan_group.location %}&location={{ vlan_group.location.pk }}{% endif %}\
" class="btn btn-xs btn-success">{{ record.available }} VLAN{{ record.available|pluralize }} available</a>\
{% else %}
...
```

<!-- What did you expect to happen? -->
### Expected Behavior


<!-- What happened instead? -->
### Observed Behavior



Discussion:

Resolving patch:
diff --git a/nautobot/ipam/tables.py b/nautobot/ipam/tables.py
--- a/nautobot/ipam/tables.py
+++ b/nautobot/ipam/tables.py
@@ -179,7 +179,6 @@
 {% url 'ipam:vlan_add' %}\
 ?vid={{ record.vid }}&vlan_group={{ vlan_group.pk }}\
 {% if vlan_group.location %}&location={{ vlan_group.location.pk }}{% endif %}\
-{% if vlan_group.location %}&location={{ vlan_group.location.pk }}{% endif %}\
 " class="btn btn-xs btn-success">{{ record.available }} VLAN{{ record.available|pluralize }} available</a>\
 {% else %}
     {{ record.available }} VLAN{{ record.available|pluralize }} available


Test patch:
Repository: nautobot/nautobot

Issue:
[v2.2] Team(s) field not pre-populating when editing a Contact
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable): 2.2.0a1
* Python version: 3.11.8
* Database platform, version: n/a
* Middleware(s): n/a

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Create a Team
2. Create a Contact and associate it to the Team
3. Edit the Contact

<!-- What did you expect to happen? -->
### Expected Behavior
The existing Team would be displayed in the edit form

<!-- What happened instead? -->
### Observed Behavior
The `Team(s)` field is empty and if you don't reapply the team it will remove it.


Discussion:

Resolving patch:
diff --git a/nautobot/extras/forms/contacts.py b/nautobot/extras/forms/contacts.py
--- a/nautobot/extras/forms/contacts.py
+++ b/nautobot/extras/forms/contacts.py
@@ -28,6 +28,13 @@ class Meta:
             "tags",
         ]
 
+    def __init__(self, instance=None, initial=None, **kwargs):
+        if instance is not None:
+            if initial is None:
+                initial = {}
+            initial.setdefault("teams", instance.teams.all())
+        super().__init__(instance=instance, initial=initial, **kwargs)
+
     def save(self, *args, **kwargs):
         """
         Since `teams` field on Contact Model is the reverse side of an M2M,


Test patch:
Repository: nautobot/nautobot

Issue:
Add total device count until device family 
### As ...

Nelly - Network Engineer

### I want ...

Under device families, when clicking the detail page of a device type, I would like to see the total devices in the device family. 

### So that ...

We can quickly tell the number of devices across different device types in a device family. 

### I know this is done when...

- I can see the total devices in a device family. 

### Optional - Feature groups this request pertains to.

- [ ] Automation
- [ ] Circuits
- [ ] DCIM
- [ ] IPAM
- [ ] Misc (including Data Sources)
- [ ] Organization
- [ ] Plugins (and other Extensibility)
- [ ] Security (Secrets, etc)
- [ ] Image Management
- [ ] UI/UX
- [ ] Documentation
- [ ] Other (not directly a platform feature)

### Database Changes

- The data already exists, no new model required. 

### External Dependencies

- no external library or dependency that I can tell


Discussion:

Resolving patch:
diff --git a/nautobot/dcim/views.py b/nautobot/dcim/views.py
--- a/nautobot/dcim/views.py
+++ b/nautobot/dcim/views.py
@@ -2978,6 +2978,12 @@ def get_extra_context(self, request, instance):
             RequestConfig(request, paginate).configure(device_type_table)
 
             context["device_type_table"] = device_type_table
+
+            total_devices = 0
+            for device_type in device_types:
+                total_devices += device_type.device_count
+            context["total_devices"] = total_devices
+
         return context
 
 


Test patch:
Repository: nautobot/nautobot

Issue:
Plugins not loaded with Gunicorn

### Environment

* Nautobot version (Docker tag too if applicable): 2.2.1
* Python version: 3.11
* Database platform, version: psql
* Middleware(s):


### Steps to Reproduce
1. Use systemd
2. With gunicorn 21.2.0 or 22.0.0


<!-- What did you expect to happen? -->
### Expected Behavior

All applications to show 

### Observed Behavior

We attempted to upgrade our dev environment from 2.1.9 to 2.2.1 but are hitting a weird issue where our plugins are reported as missing.  We are only loading 1 or 2 basic plugins right now while we work on updating all our other plugins for 2.x.  Oddly we are only seeing this issue on 1 out of 3 identical servers with identical Nautobot installs.

This looks very much like this issue from 2021: [Plugin Load Failure · Issue #95 · nautobot/nautobot (github.com)](https://github.com/nautobot/nautobot/issues/95)


Discussion:
Re-adding the `nautobot.setup()` call to `nautobot/core/wsgi.py` [here](https://github.com/nautobot/nautobot/pull/5310/files#diff-32ef18b2e4ae31a3c7c252c479ad8929f9b9a304a2924cd4c66a1320c01f126eL7-L15) resolves this issue. @glennmatthews do you see any problems with making this change?

Resolving patch:
diff --git a/nautobot/core/wsgi.py b/nautobot/core/wsgi.py
--- a/nautobot/core/wsgi.py
+++ b/nautobot/core/wsgi.py
@@ -1,11 +1,18 @@
 import logging
-import os
 
 from django.core import cache
 from django.core.wsgi import get_wsgi_application
 from django.db import connections
 
-os.environ["DJANGO_SETTINGS_MODULE"] = "nautobot_config"
+import nautobot
+
+# This is the Django default left here for visibility on how the Nautobot pattern
+# differs.
+# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nautobot.core.settings")
+
+# Instead of just pointing to `DJANGO_SETTINGS_MODULE` and letting Django run with it,
+# we're using the custom Nautobot loader code to read environment or config path for us.
+nautobot.setup()
 
 # Use try/except because we might not be running uWSGI. If `settings.WEBSERVER_WARMUP` is `True`,
 # will first call `get_internal_wsgi_application` which does not have `uwsgi` module loaded


Test patch:
Repository: nautobot/nautobot

Issue:
Job tiles view doesn't understand `per_page` and `page` query parameters
### Environment
* Nautobot version (Docker tag too if applicable): 2.2.1

### Steps to Reproduce
1. Switch to Job "tiles" view
2. Select any pagination value from the "per page" dropdown at the bottom right, or add "&per_page=1" to the query parameters in your browser - first error is seen
3. Remove the query parameter from the URL and refresh the page - page loads successfully with the previously specified pagination value applied
4. Try to switch to a later page of results via the widget in the bottom right, or add "&page=2" to the query parameters - second error is seen

<!-- What did you expect to happen? -->
### Expected Behavior

Page to paginate properly

<!-- What happened instead? -->
### Observed Behavior

![image](https://github.com/nautobot/nautobot/assets/5603551/acb4e010-92ca-4117-987e-6906bd4acead)
![image](https://github.com/nautobot/nautobot/assets/5603551/489fe6fd-1ecb-4626-9a8e-f0a3f2c70409)



Discussion:

Resolving patch:
diff --git a/nautobot/extras/views.py b/nautobot/extras/views.py
--- a/nautobot/extras/views.py
+++ b/nautobot/extras/views.py
@@ -1250,7 +1250,10 @@ class JobListView(generic.ObjectListView):
     filterset = filters.JobFilterSet
     filterset_form = forms.JobFilterForm
     action_buttons = ()
-    non_filter_params = ("display",)
+    non_filter_params = (
+        *generic.ObjectListView.non_filter_params,
+        "display",
+    )
     template_name = "extras/job_list.html"
 
     def alter_queryset(self, request):


Test patch:
Repository: nautobot/nautobot

Issue:
Device Redundancy Groups Not Working for Config Contexts from Git
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for reporting reproducible bugs. If you need assistance
    with Nautobot installation, or if you have a general question, please start a
    discussion instead: https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot. Be sure
    that you are running an unmodified instance of the latest stable release
    before submitting a bug report, and that any plugins have been disabled.
-->
### Environment
* Nautobot version (Docker tag too if applicable): 2.2.0
* Python version: 3.10
* Database platform, version: Postgres
* Middleware(s): N/A

<!--
    Describe in detail the exact steps that someone else can take to reproduce
    this bug using the current stable release of Nautobot. Begin with the
    creation of any necessary database objects and call out every operation
    being performed explicitly. If reporting a bug in the REST API, be sure to
    reconstruct the raw HTTP request(s) being made: Don't rely on a client
    library such as pynautobot.
-->
### Steps to Reproduce
1. Create config context with device_redundancy_groups key in metadata.
2. Import config context into Nautobot.
3. Look at config context in Nautobot UI and see that Device Redundancy Group assignment is None.

<!-- What did you expect to happen? -->
### Expected Behavior
Expect that Device Redundancy Groups defined in key should be assigned to Config Context.

<!-- What happened instead? -->
### Observed Behavior
Device Redundancy Groups are never assigned.


Discussion:
I believe this is due to [this](https://github.com/nautobot/nautobot/blob/develop/nautobot/extras/datasources/git.py#L395) part of the code not including Device Redundancy Groups in the list.

Resolving patch:
diff --git a/nautobot/extras/datasources/git.py b/nautobot/extras/datasources/git.py
--- a/nautobot/extras/datasources/git.py
+++ b/nautobot/extras/datasources/git.py
@@ -19,7 +19,7 @@
 
 from nautobot.core.celery import app as celery_app
 from nautobot.core.utils.git import GitRepo
-from nautobot.dcim.models import Device, DeviceType, Location, Platform
+from nautobot.dcim.models import Device, DeviceRedundancyGroup, DeviceType, Location, Platform
 from nautobot.extras.choices import (
     LogLevelChoices,
     SecretsGroupAccessTypeChoices,
@@ -272,6 +272,7 @@ def update_git_config_contexts(repository_record, job_result):
         "tenants",
         "tags",
         "dynamic_groups",
+        "device_redundancy_groups",
     ):
         if os.path.isdir(os.path.join(repository_record.filesystem_path, filter_type)):
             msg = (
@@ -402,6 +403,7 @@ def import_config_context(context_data, repository_record, job_result):
         ("tenants", Tenant),
         ("tags", Tag),
         ("dynamic_groups", DynamicGroup),
+        ("device_redundancy_groups", DeviceRedundancyGroup),
     ]:
         relations[key] = []
         for object_data in context_metadata.get(key, ()):


Test patch:
Repository: nautobot/nautobot

Issue:
Add Family column to Device Types table
### Environment
* Nautobot version (Docker tag too if applicable): 2.2.3
* Python version: 3.11
* Database platform, version: postgres 15
* Middleware(s):

### Steps to Reproduce
1. Go to Device Types list https://demo.nautobot.com/dcim/device-types/
2. Try to add Family in Table Configuration
3. Family is not in the list of available columns

#3559 #5040 
https://github.com/nautobot/nautobot/blob/42440ebd9b381534ad89d62420ebea00d703d64e/nautobot/dcim/tables/devicetypes.py#L95

### Expected Behavior
Family column can be selected in Device Types list

### Observed Behavior
Family column is not in the list of available columns
Add Family column to Device Types table
### Environment
* Nautobot version (Docker tag too if applicable): 2.2.3
* Python version: 3.11
* Database platform, version: postgres 15
* Middleware(s):

### Steps to Reproduce
1. Go to Device Types list https://demo.nautobot.com/dcim/device-types/
2. Try to add Family in Table Configuration
3. Family is not in the list of available columns

#3559 #5040 
https://github.com/nautobot/nautobot/blob/42440ebd9b381534ad89d62420ebea00d703d64e/nautobot/dcim/tables/devicetypes.py#L95

### Expected Behavior
Family column can be selected in Device Types list

### Observed Behavior
Family column is not in the list of available columns


Discussion:
Thanks for the report!
Thanks for the report!

Resolving patch:
diff --git a/nautobot/dcim/tables/devicetypes.py b/nautobot/dcim/tables/devicetypes.py
--- a/nautobot/dcim/tables/devicetypes.py
+++ b/nautobot/dcim/tables/devicetypes.py
@@ -103,6 +103,8 @@ class Meta(BaseTable.Meta):
 class DeviceTypeTable(BaseTable):
     pk = ToggleColumn()
     model = tables.Column(linkify=True, verbose_name="Device Type")
+    manufacturer = tables.Column(linkify=True)
+    device_family = tables.Column(linkify=True)
     is_full_depth = BooleanColumn(verbose_name="Full Depth")
     device_count = LinkedCountColumn(
         viewname="dcim:device_list",
@@ -117,6 +119,7 @@ class Meta(BaseTable.Meta):
             "pk",
             "model",
             "manufacturer",
+            "device_family",
             "part_number",
             "u_height",
             "is_full_depth",


Test patch:
Repository: ansible/ansible-lint

Issue:
Parseable format
The quiet output is `[<ERROR_ID>] <FILE>:<LINE>`

I may be mistaken, but I was under the impression that the format `<FILE>:<LINE>: <ERROR_ID>` was more commonly used − eg pep8, pylint or cpplint.

Could the output be changed, or a `parseable` output implemented?

My use case being: I would like to track ansible-lint violations in a Jenkins job, and I would love to _not have_ to add a Parser to some plugin. :-)



Discussion:
(Happy to submit a pull request to `formatters/__init__.py` is you like the idea).

(Fixed formatting of first post, with unreadable bits)

How about some kind of option that allows output format using various keys - e.g.
`--format "%{file}:%{line}: %{code} %{message}"`
and then passing that to the output. I'm not really sure what other people are doing with output parsing so I wouldn't like to change the default (even if it is more widely used elsewhere)

Note that line number is not generally accurate (or set) except in the `matchline` task. But you probably know that already.


Resolving patch:
diff --git a/lib/ansiblelint/formatters/__init__.py b/lib/ansiblelint/formatters/__init__.py
--- a/lib/ansiblelint/formatters/__init__.py
+++ b/lib/ansiblelint/formatters/__init__.py
@@ -15,3 +15,14 @@ def format(self, match):
         formatstr = "[{0}] {1}:{2}"
         return formatstr.format(match.rule.id, match.filename,
                                 match.linenumber)
+
+
+class ParseableFormatter:
+
+    def format(self, match):
+        formatstr = "{0}:{1}: {2} {3}"
+        return formatstr.format(match.filename,
+                                match.linenumber,
+                                match.rule.id,
+                                match.message,
+                                )


Test patch:
Repository: ansible/ansible-lint

Issue:
AnsibleParseError generate full traceback dumps which break lint output consumers.
It seems that exceptions like the one documented on https://github.com/mschuchard/linter-ansible-linting/issues/3 do make almost impossible to integrate it with other apps, like the atom-linter.

I do agree the traceback dumps are very useful for debugging, they are not what you would expect from a normal tool execution.

Maybe adding a parameter for disabling them would sort this issue?

<img width="448" alt="screenshot 2016-03-21 10 23 54" src="https://cloud.githubusercontent.com/assets/102495/13921342/4a7fe96a-ef6f-11e5-92fc-6262d5c76944.png">



Discussion:
Please use the issue template when raising issues.

It would be helpful in this case as to what you would expect ansible-lint to do with a broken playbook. You're correct that a stack trace isn't ideal, but neither do I want to just silence all possible error scenarios.

It might also make sense to run ansible-playbook --syntax-check on your playbooks as a pre-check to running ansible-lint

```
[ansible-lint (master)]$ ansible-playbook --syntax-check test/norole.yml -i localhost,
ERROR: Syntax Error while loading YAML script, test/norole.yml
Note: The error may actually appear before this position: line 3, column 8

- hosts:localhost
  roles:
       ^
```

And with the fix to `- hosts: localhost`:

```
[ansible-lint (master)]$ ansible-playbook --syntax-check test/norole.yml -i localhost,

playbook: test/norole.yml

ERROR: expected a role name in dictionary: {'name': 'xxx'}
```


Resolving patch:
diff --git a/lib/ansiblelint/utils.py b/lib/ansiblelint/utils.py
--- a/lib/ansiblelint/utils.py
+++ b/lib/ansiblelint/utils.py
@@ -23,6 +23,7 @@
 import os
 
 import ansible.constants as C
+from ansible.errors import AnsibleError
 from ansible.module_utils.splitter import split_args
 
 import yaml
@@ -116,7 +117,10 @@ def find_children(playbook):
         return []
     results = []
     basedir = os.path.dirname(playbook[0])
-    pb_data = parse_yaml_from_file(playbook[0])
+    try:
+        pb_data = parse_yaml_from_file(playbook[0])
+    except AnsibleError, e:
+        raise SystemExit(str(e))
     items = _playbook_items(pb_data)
     for item in items:
         for child in play_children(basedir, item, playbook[1]):
@@ -173,7 +177,10 @@ def _roles_children(basedir, k, v, parent_type):
     results = []
     for role in v:
         if isinstance(role, dict):
-            results.extend(_look_for_role_files(basedir, role['role']))
+            if 'role' in role:
+                results.extend(_look_for_role_files(basedir, role['role']))
+            else:
+                raise SystemExit('role dict {0} does not contain a "role" key'.format(role))
         else:
             results.extend(_look_for_role_files(basedir, role))
     return results


Test patch: