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

Issue:
404 error when attempting to delete a RelationshipAssociation from the list view
<!--
    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
* Python version:
* Nautobot version: 1.0.0b4

<!--
    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 Relationship between models, and apply this relationship to at least one model (creating a RelationshipAssociation record)
2. Navigate to the RelationshipAssociation list view at `/extras/relationships/associations/`
3. Click the Delete button next to any entry in the table

<!-- What did you expect to happen? -->
### Expected Behavior

The association is deleted, perhaps after a confirmation prompt

<!-- What happened instead? -->
### Observed Behavior

404 error:

![image](https://user-images.githubusercontent.com/5603551/114938419-16d8c300-9e0d-11eb-884f-50b94535a77a.png)

I note that the 404 page URL is (for example) `extras/relationships/58197042-7627-41cc-8073-ce33f8f74e1c/delete/?return_url=/extras/relationships/associations/`, but it almost certainly should be `extras/relationships/**associations**/58197042-7627-41cc-8073-ce33f8f74e1c/delete/?return_url=/extras/relationships/associations/`


Discussion:

Resolving patch:
diff --git a/nautobot/extras/tables.py b/nautobot/extras/tables.py
--- a/nautobot/extras/tables.py
+++ b/nautobot/extras/tables.py
@@ -409,7 +409,7 @@ class Meta(BaseTable.Meta):
 
 class RelationshipAssociationTable(BaseTable):
     pk = ToggleColumn()
-    actions = ButtonsColumn(Relationship, buttons=("delete",))
+    actions = ButtonsColumn(RelationshipAssociation, buttons=("delete",))
 
     source = tables.Column(linkify=True)
 


Test patch:
Repository: nautobot/nautobot

Issue:
`nautobot.core.api.serializers.WritableNestedSerializer` docstring is incorrect and confusing
<!--
    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
The docstring should read something like this:
> Returns a nested representation of an object on read, but accepts either the nested representation or just the PK value on write operations.

<!-- Provide justification for the proposed change(s). -->
### Justification
The current docstring is in conflict with the actual implementation by stating that only the PK value is supported on write, which is incorrect.


Discussion:
Good call! I've been confused by exactly this in the past. :-)
I can start with this first good issue. 

Resolving patch:
diff --git a/nautobot/core/api/serializers.py b/nautobot/core/api/serializers.py
--- a/nautobot/core/api/serializers.py
+++ b/nautobot/core/api/serializers.py
@@ -77,7 +77,8 @@ def validate(self, data):
 
 class WritableNestedSerializer(BaseModelSerializer):
     """
-    Returns a nested representation of an object on read, but accepts only a primary key on write.
+    Returns a nested representation of an object on read, but accepts either the nested representation or the
+    primary key value on write operations.
     """
 
     def to_internal_value(self, data):


Test patch:
Repository: nautobot/nautobot

Issue:
Migrate user, social auth, and system settings from Django Admin to be first-class citizens in UI/API
### Proposed Functionality 

Before the launch of Nautobot, there was significant work to migrate functionality from Django Admin into core and create first-class views and APIs for webhooks, custom links, and export templates.  Custom fields are also coming soon in #229.  This proposes doing the same for everything in the Users, Python Social Auth, and System sections in Django Admin.

### Use Cases

As Patti the Platform Admin,
I want to have the ability to manage users, groups, and permissions from the Nautobot UI without going into Django Admin,
So that there is a more consistent user experience for my team as well as APIs for anything else that doesn't have an API currently within Django Admin, e.g. Social Auth, retrieving background tasks, etc. 

One option is to create an "Admin" dropdown in the navigation bar which contains "Users (no change)," "Social Auth (drop 'Python')," and "System" sections. We may need one additional section called "plugins" for when plugins have created entries in Django Admin.

I will know this is done when it is possible to:
* Manage what is currently under Users, Python Social Auth, and System sections in Django Admin in the main Nautobot UI
* Manage what is currently under Users, Python Social Auth, and System sections in Django Admin through Nautobot REST API calls



Discussion:

Resolving patch:
diff --git a/nautobot/core/admin.py b/nautobot/core/admin.py
--- a/nautobot/core/admin.py
+++ b/nautobot/core/admin.py
@@ -1,5 +1,6 @@
 from django.conf import settings
 from django.contrib.admin import site as admin_site
+from social_django.models import Association, Nonce, UserSocialAuth
 from taggit.models import Tag
 
 
@@ -11,3 +12,8 @@
 
 # Unregister the unused stock Tag model provided by django-taggit
 admin_site.unregister(Tag)
+
+# Unregister SocialAuth from Django admin menu
+admin_site.unregister(Association)
+admin_site.unregister(Nonce)
+admin_site.unregister(UserSocialAuth)


Test patch:
Repository: nautobot/nautobot

Issue:
Git Sync - Include Commit Hash on Sync Page
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for proposing specific new features or enhancements.
    If you have a general idea or question, please start a discussion instead:
    https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot.
-->
### Environment
* Python version: 3.6
* Nautobot version: 1.0.3

<!--
    Describe in detail the new functionality you are proposing. Include any
    specific changes to work flows, data models, or the user interface.
-->
### Proposed Functionality

Add the Git hash to the git sync output display

<!--
    Convey an example use case for your proposed feature. Write from the
    perspective of a Nautobot user who would benefit from the proposed
    functionality and describe how.
--->
### Use Case

To be able to verify the commit hash matches the version that is expected for troubleshooting.


<!--
    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:
Thank you for the request! I agree this would be useful information to include in the JobResult logging, and should be relatively simple to add.
@glennmatthews @jvanderaa I'd like to give this one a shot.
Terrific! By all means go for it.
@jeffkala what's your timing on this?  If it is in the next 2-3 weeks, it'll make 1.2, otherwise, 1.3.  Can you let us know? :) 
@jedelman8 , pretty sure I can get this in the next 2-3 weeks.

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
@@ -86,6 +86,12 @@ def pull_git_repository_and_refresh_data(repository_pk, request, job_result_pk):
             logger=logger,
         )
 
+        job_result.log(
+            f'The current Git repository hash is "{repository_record.current_head}"',
+            level_choice=LogLevelChoices.LOG_INFO,
+            logger=logger,
+        )
+
         refresh_datasource_content("extras.gitrepository", repository_record, request, job_result, delete=False)
 
     except Exception as exc:


Test patch:
Repository: nautobot/nautobot

Issue:
Jobs Approval Queue page Action buttons need tool tips 
<!--
    NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED.

    This form is only for proposing specific new features or enhancements.
    If you have a general idea or question, please start a discussion instead:
    https://github.com/nautobot/nautobot/discussions

    Please describe the environment in which you are running Nautobot.
-->
### Environment
* Python version: 3.8
* Nautobot version: 1.2.0a1

<!--
    Describe in detail the new functionality you are proposing. Include any
    specific changes to work flows, data models, or the user interface.
-->
### Proposed Functionality

The Jobs Approval Queue page should have tool tips for the Actions buttons

![image](https://user-images.githubusercontent.com/13647153/134410921-251d7c40-246c-4245-9bda-adf38fef04b7.png)


<!--
    Convey an example use case for your proposed feature. Write from the
    perspective of a Nautobot user who would benefit from the proposed
    functionality and describe how.
--->
### Use Case

It's fairly obvious that the red X Action button denies the approval.  It's not entirely clear what the difference between the green check button and the play button are (dry-run vs approve).  The user should see the function when hovering over the button.




Discussion:

Resolving patch:
diff --git a/nautobot/extras/tables.py b/nautobot/extras/tables.py
--- a/nautobot/extras/tables.py
+++ b/nautobot/extras/tables.py
@@ -82,16 +82,19 @@
 SCHEDULED_JOB_APPROVAL_QUEUE_BUTTONS = """
 <button type="button"
         onClick="handleDetailPostAction('{% url 'extras:scheduledjob_approval_request_view' scheduled_job=record.pk %}', '_dry_run')"
+        title="Dry Run"
         class="btn btn-primary btn-xs"{% if not perms.extras.run_job %} disabled="disabled"{% endif %}>
     <i class="mdi mdi-play"></i>
 </button>
 <button type="button"
         onClick="handleDetailPostAction('{% url 'extras:scheduledjob_approval_request_view' scheduled_job=record.pk %}', '_approve')"
+        title="Approve"
         class="btn btn-success btn-xs"{% if not perms.extras.run_job %} disabled="disabled"{% endif %}>
     <i class="mdi mdi-check"></i>
 </button>
 <button type="button"
         onClick="handleDetailPostAction('{% url 'extras:scheduledjob_approval_request_view' scheduled_job=record.pk %}', '_deny')"
+        title="Deny"
         class="btn btn-danger btn-xs"{% if not perms.extras.run_job %} disabled="disabled"{% endif %}>
     <i class="mdi mdi-close"></i>
 </button>


Test patch:
Repository: nautobot/nautobot

Issue:
Change HomePageItem link validation from initialize-time to run-time
<!--
    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

Similar to the changes made for 1.1.x and NavMenuItems in https://github.com/nautobot/nautobot/pull/789, the HomePageItems shouldn't be calling `reverse()` during initialization as it means that a bad link will cause the entire Nautobot app to fail to start up. Instead, bad URLs should be handled at homepage render time and render an appropriate error message inline.


<!-- Provide justification for the proposed change(s). -->
### Justification

More graceful error handling; prevent a bad link in a plugin home page extension from breaking the entire application.


Discussion:

Resolving patch:
diff --git a/nautobot/core/apps/__init__.py b/nautobot/core/apps/__init__.py
--- a/nautobot/core/apps/__init__.py
+++ b/nautobot/core/apps/__init__.py
@@ -4,7 +4,6 @@
 from abc import ABC, abstractproperty
 from django.apps import AppConfig, apps as global_apps
 from django.db.models.signals import post_migrate
-from django.urls import reverse
 from collections import OrderedDict
 
 from nautobot.core.signals import nautobot_database_ready
@@ -390,8 +389,6 @@ def __init__(
             custom_data (dict): Custom data to be passed to the custom template.
         """
         super().__init__(permissions)
-        if link:
-            reverse(link)
 
         self.name = name
         self.custom_template = custom_template


Test patch:
Repository: nautobot/nautobot

Issue:
Local variable 'username' referenced before assignment error when querying device status
### Environment

* Python version: 3.9.9
* Nautobot version: v1.2.0b1

### Steps to Reproduce

1. Set NAUTOBOT_NAPALM_USERNAME and NAUTOBOT_NAPALM_PASSWORD environment variables
1. Add a device with primary management interface/IP (device is a Cisco XRv in my case)
2. Go to device status tab

### Expected Behavior

View device status

### Observed Behavior

UnboundLocalError exception is thrown with error message "local variable 'username' referenced before assignment"


Discussion:

Resolving patch:
diff --git a/nautobot/dcim/api/views.py b/nautobot/dcim/api/views.py
--- a/nautobot/dcim/api/views.py
+++ b/nautobot/dcim/api/views.py
@@ -494,6 +494,9 @@ def napalm(self, request, pk):
                     password = settings.NAPALM_PASSWORD
             except SecretError as exc:
                 raise ServiceUnavailable(f"Unable to retrieve device credentials: {exc.message}") from exc
+        else:
+            username = settings.NAPALM_USERNAME
+            password = settings.NAPALM_PASSWORD
 
         optional_args = settings.NAPALM_ARGS.copy()
         if device.platform.napalm_args is not None:


Test patch:
Repository: nautobot/nautobot

Issue:
Job view using query params to set multiple values of a MultiObjectVar only uses last provided value

### Environment
* Python version: 3.7
* Nautobot version: 1.1.3

### Steps to Reproduce
1. Build a job with MultiObjectVar
2. Leverage query params to add multiple entries
3. Observer that only a single entry was shown

Example URL pattern (showing the same pattern in ObjectListView filters)
https://demo.nautobot.com/extras/jobs/plugins/nautobot_golden_config.jobs/AllDevicesGoldenConfig/?device=5f399552-f541-4bb4-9379-e67bbef56fe6&device=cad377c0-1ca3-4bad-a940-b4aa275fcf9e



### Expected Behavior

Multiple filtered objects. 

### Observed Behavior

Visual to show that there are two uuid's, and only the last one get's used. 
![image](https://user-images.githubusercontent.com/9260483/133907103-7072cb92-9826-4789-bee4-622b906f6736.png)



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
@@ -34,6 +34,7 @@
 )
 from nautobot.utilities.tables import ButtonsColumn
 from nautobot.utilities.views import ContentTypePermissionRequiredMixin
+from nautobot.utilities.utils import normalize_querydict
 from nautobot.virtualization.models import VirtualMachine
 from nautobot.virtualization.tables import VirtualMachineTable
 from . import filters, forms, tables
@@ -775,8 +776,8 @@ def get(self, request, class_path):
         job = job_class()
         grouping, module, class_name = class_path.split("/", 2)
 
-        job_form = job.as_form(initial=request.GET)
-        schedule_form = forms.JobScheduleForm(initial=request.GET)
+        job_form = job.as_form(initial=normalize_querydict(request.GET))
+        schedule_form = forms.JobScheduleForm(initial=normalize_querydict(request.GET))
 
         return render(
             request,
diff --git a/nautobot/virtualization/views.py b/nautobot/virtualization/views.py
--- a/nautobot/virtualization/views.py
+++ b/nautobot/virtualization/views.py
@@ -13,6 +13,7 @@
 from nautobot.ipam.tables import InterfaceIPAddressTable, InterfaceVLANTable
 from nautobot.utilities.paginator import EnhancedPaginator, get_paginate_count
 from nautobot.utilities.utils import count_related
+from nautobot.utilities.utils import normalize_querydict
 from . import filters, forms, tables
 from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterface
 
@@ -199,7 +200,7 @@ class ClusterAddDevicesView(generic.ObjectEditView):
 
     def get(self, request, pk):
         cluster = get_object_or_404(self.queryset, pk=pk)
-        form = self.form(cluster, initial=request.GET)
+        form = self.form(cluster, initial=normalize_querydict(request.GET))
 
         return render(
             request,


Test patch:
Repository: nautobot/nautobot

Issue:
Refinements to Constance (config) admin UI
### Proposed Changes

- Investigate whether URL path can easily be changed from `admin/constance/config/` to `admin/configuration/config`.
- Set a minimum width on the property names column to avoid cases like:
![image](https://user-images.githubusercontent.com/5603551/142893760-c6309e9f-341a-4398-bf8d-f6de20a17379.png)
- Add a banner to the template warning that configuration here is overridden by explicit configuration in `nautobot_config.py`
  - It would be great if we could even add specific warnings about individual config properties that **are** overridden thusly.

### Justification

UI review.



Discussion:

Resolving patch:
diff --git a/nautobot/utilities/templatetags/helpers.py b/nautobot/utilities/templatetags/helpers.py
--- a/nautobot/utilities/templatetags/helpers.py
+++ b/nautobot/utilities/templatetags/helpers.py
@@ -250,11 +250,24 @@ def settings_or_config(key):
     return get_settings_or_config(key)
 
 
+@register.filter
+def quote_string(value):
+    """Add literal quote characters around the provided value if it's a string."""
+    if isinstance(value, str):
+        return f'"{value}"'
+    return value
+
+
 #
 # Tags
 #
 
 
+@register.simple_tag()
+def get_attr(obj, attr, default=None):
+    return getattr(obj, attr, default)
+
+
 @register.simple_tag()
 def querystring(request, **kwargs):
     """


Test patch:
Repository: nautobot/nautobot

Issue:
JobResult page may fail to list JobLogEntries in chronological order
### Environment
* Python version: 3.6
* Nautobot version: 1.2.1

### Steps to Reproduce
Unsure at this time

<!-- What did you expect to happen? -->
### Expected Behavior

JobLogEntries to be listed in chronological order.

<!-- What happened instead? -->
### Observed Behavior

![image](https://user-images.githubusercontent.com/5603551/146831919-5afa877d-f07c-4bf6-838b-3c8c56c1c064.png)

Looking at the code, either the `JobLogEntry` class should define a `Meta.ordering` property, or else the `GitRepositoryResultView` and `JobResultView` view should add an `order_by()` to their `JobLogEntry` querysets.


Discussion:
Also, using `settings.SHORT_DATETIME_FORMAT` for this column is probably not ideal as it only gives minute-level precision. For most jobs, a `HH:MM:SS.mmm` display would probably be more useful.

Resolving patch:
diff --git a/nautobot/extras/tables.py b/nautobot/extras/tables.py
--- a/nautobot/extras/tables.py
+++ b/nautobot/extras/tables.py
@@ -389,7 +389,7 @@ def log_entry_color_css(record):
 
 
 class JobLogEntryTable(BaseTable):
-    created = tables.DateTimeColumn(verbose_name="Time", format=settings.SHORT_DATETIME_FORMAT)
+    created = tables.DateTimeColumn(verbose_name="Time", format="Y-m-d H:i:s.u")
     grouping = tables.Column()
     log_level = tables.Column(
         verbose_name="Level",


Test patch:
Repository: nautobot/nautobot

Issue:
JobLogEntry message text not rendered as Markdown
### Environment
* Python version: 3.6
* Nautobot version: 1.2.1

### Steps to Reproduce
1. Run a Job which outputs a log message containing Markdown formatting, such as ``"hello *world*, this is `Job`."``
2. View the job result page for this run.

<!-- What did you expect to happen? -->
### Expected Behavior

Markdown formatting to be rendered as it was in 1.1.x.

### Observed Behavior

Message text is presented as-is, without formatting:

![image](https://user-images.githubusercontent.com/5603551/146835444-3d917db4-b714-4af1-8b17-c0104bbcdbf3.png)



Discussion:

Resolving patch:
diff --git a/nautobot/extras/tables.py b/nautobot/extras/tables.py
--- a/nautobot/extras/tables.py
+++ b/nautobot/extras/tables.py
@@ -396,7 +396,9 @@ class JobLogEntryTable(BaseTable):
         attrs={"td": {"class": "text-nowrap report-stats"}},
     )
     log_object = tables.Column(verbose_name="Object", linkify=log_object_link)
-    message = tables.Column()
+    message = tables.Column(
+        attrs={"td": {"class": "rendered-markdown"}},
+    )
 
     def render_log_level(self, value):
         log_level = value.lower()
@@ -406,6 +408,9 @@ def render_log_level(self, value):
 
         return format_html('<label class="label label-{}">{}</label>', log_level, value)
 
+    def render_message(self, value):
+        return render_markdown(value)
+
     class Meta(BaseTable.Meta):
         model = JobLogEntry
         fields = ("created", "grouping", "log_level", "log_object", "message")


Test patch:
Repository: nautobot/nautobot

Issue:
Include IP in device view export
### As ...

Ozzie - Operator

### I want ...

have IP address column in my device UI export 

### So that ...

I can easily work with device/IP relation, for example compare the data with another system.

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

- Exporting from device view returns IP address column too

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

- [ ] Automation
- [ ] Circuits
- [X] 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

None

### External Dependencies

None


Discussion:

Resolving patch:
diff --git a/nautobot/dcim/models/devices.py b/nautobot/dcim/models/devices.py
--- a/nautobot/dcim/models/devices.py
+++ b/nautobot/dcim/models/devices.py
@@ -561,6 +561,7 @@ class Device(PrimaryModel, ConfigContextModel, StatusModel):
         "position",
         "face",
         "secrets_group",
+        "primary_ip",
         "comments",
     ]
     clone_fields = [
@@ -783,6 +784,7 @@ def to_csv(self):
             self.position,
             self.get_face_display(),
             self.secrets_group.name if self.secrets_group else None,
+            self.primary_ip if self.primary_ip else None,
             self.comments,
         )
 


Test patch: