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

Issue:
LDAP Group Type documentation link broken
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
 - UI

##### SUMMARY
In the helptext for the LDAP Group Type documentation (Configuration -> Authentication -> Sub Category = LDAP), the following text is shown.

> #### LDAP Group Type
> The group type may need to be changed based on the type of the LDAP server. Values are listed at: http://pythonhosted.org/django-auth-ldap/groups.html#types-of-groups

However, this link is broken. The new path for the best-matching documentation I could find is

> http://django-auth-ldap.readthedocs.io/en/latest/groups.html

##### ENVIRONMENT
* AWX version: 1.0.0.521 (self-built)
* Ansible version:  2.3.1.0
* Operating System: CentOS 7
* Web Browser: Firefox

##### STEPS TO REPRODUCE

At the Web UI, navigate to Configuration -> Authentication -> Sub Category = LDAP, then hover over the `?` to the right of `LDAP GROUP TYPE`. Try to visit the given link, and find that it gives a 404 error.

##### EXPECTED RESULTS

The link should yield actual documentation of the Django LDAP group types.

##### ACTUAL RESULTS

Broken link.



Discussion:
https://django-auth-ldap.readthedocs.io/en/stable/groups.html#types-of-groups

Resolving patch:
diff --git a/awx/sso/conf.py b/awx/sso/conf.py
--- a/awx/sso/conf.py
+++ b/awx/sso/conf.py
@@ -286,7 +286,7 @@ def __call__(self):
     label=_('LDAP Group Type'),
     help_text=_('The group type may need to be changed based on the type of the '
                 'LDAP server.  Values are listed at: '
-                'http://pythonhosted.org/django-auth-ldap/groups.html#types-of-groups'),
+                'https://django-auth-ldap.readthedocs.io/en/stable/groups.html#types-of-groups'),
     category=_('LDAP'),
     category_slug='ldap',
     feature_required='ldap',


Test patch:
Repository: ansible/awx

Issue:
RFE: awx-cli job monitor command
##### ISSUE TYPE
 - Feature Idea

##### SUMMARY
Add a monitor parameter to the job resource with cli to be able to monitor currently running jobs. Currently, it is only possible to monitor a job a launch with the --monitor flag.

(similar to https://tower-cli.readthedocs.io/en/latest/api_ref/resources/job.html#tower_cli.resources.job.Resource.monitor)


Discussion:

Resolving patch:
diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py
--- a/awxkit/awxkit/cli/custom.py
+++ b/awxkit/awxkit/cli/custom.py
@@ -552,3 +552,41 @@ def is_json(self, data):
         except json.decoder.JSONDecodeError:
             return False
         return True
+
+
+class HasMonitor(object):
+
+    action = 'monitor'
+
+    def add_arguments(self, parser, resource_options_parser):
+        from .options import pk_or_name
+        parser.choices[self.action].add_argument(
+            'id',
+            type=functools.partial(
+                pk_or_name, None, self.resource, page=self.page
+            ),
+            help=''
+        )
+
+    def perform(self, **kwargs):
+        response = self.page.get()
+        mon = monitor_workflow if response.type == 'workflow_job' else monitor
+        if not response.failed and response.status != 'successful':
+            status = mon(
+                response,
+                self.page.connection.session,
+            )
+            if status:
+                response.json['status'] = status
+                if status in ('failed', 'error'):
+                    setattr(response, 'rc', 1)
+        else:
+            return 'Unable to monitor finished job'
+
+
+class JobMonitor(HasMonitor, CustomAction):
+    resource = 'jobs'
+
+
+class WorkflowJobMonitor(HasMonitor, CustomAction):
+    resource = 'workflow_jobs'


Test patch:
Repository: ansible/awx

Issue:
Mattermost Notification fails on latest release
##### ISSUE TYPE
 - Bug Report

##### SUMMARY
Trying to send a (test) notification to a Mattermost Channel fails with
```
 mattermostinfo: Notification failed.
Error sending notification mattermost: {"id":"api.webhook.incoming.error","message":"Could not decode the multipart payload of incoming webhook.","detailed_error":"","request_id":"<request ID>","status_code":400}
```
##### ENVIRONMENT
* AWX version: 11.2.0
* AWX install method: docker on linux
* Ansible version:  2.9.7
* Operating System: CentOS 7.8
* Web Browser: Chrome,Chromium,Firefox
* Mattermost Server Version: 5.22.1

##### STEPS TO REPRODUCE
- Create an incomming webhook
- Create a mattermost notification
- Send a test notification


##### EXPECTED RESULTS
Having a notification in the Channel


##### ACTUAL RESULTS

Sending failed with above error message

##### ADDITIONAL INFORMATION

The error message in the mattermost log shows
```
{"level":"error","ts":1591342011.6592789,"caller":"mlog/log.go:175","msg":"Could not decode the multipart payload of incoming webhook.","path":"/
hooks/<hook ID>","request_id":"<request ID>","ip_addr":"<IP Address>","user_id":"","method":"POST","err_where":"
incomingWebhook","http_code":400,"err_details":"mime: no media type"}
```
---
edit: some ID removed in the log sample, mattermost server version added


Discussion:
This was broken and fixed in upstream (mattermost) https://github.com/mattermost/mattermost-server/commit/beadeaf8b56f9c4e33e70069e55e5cdf12981cf6 -- But might take a while to go into a release.

Apparently AWX sends the wrong (or no) content-type

Resolving patch:
diff --git a/awx/main/notifications/mattermost_backend.py b/awx/main/notifications/mattermost_backend.py
--- a/awx/main/notifications/mattermost_backend.py
+++ b/awx/main/notifications/mattermost_backend.py
@@ -3,7 +3,6 @@
 
 import logging
 import requests
-import json
 
 from django.utils.encoding import smart_text
 from django.utils.translation import ugettext_lazy as _
@@ -45,7 +44,7 @@ def send_messages(self, messages):
             payload['text'] = m.subject
 
             r = requests.post("{}".format(m.recipients()[0]),
-                              data=json.dumps(payload), verify=(not self.mattermost_no_verify_ssl))
+                              json=payload, verify=(not self.mattermost_no_verify_ssl))
             if r.status_code >= 400:
                 logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
                 if not self.fail_silently:


Test patch:
Repository: ansible/awx

Issue:
Support `!include` and `!import` constructors in `awx import -f yaml` command
<!-- Issues are for **concrete, actionable bugs and feature requests** only - if you're just asking for debugging help or technical support, please use:

- http://webchat.freenode.net/?channels=ansible-awx
- https://groups.google.com/forum/#!forum/awx-project

We have to limit this because of limited volunteer time to respond to issues! -->

##### ISSUE TYPE
 - Feature Idea

##### SUMMARY
<!-- Briefly describe the problem or desired enhancement. -->

Support `!import` and `!include` with `awx import -f yaml` command. This is useful when working with a large number of AWX resources. This allows breaking config into smaller files, and having a top-level file like this:

```yaml
# resources.yaml
projects:
- !include projects/project1.yaml
- !include projects/project2.yaml
job_templates:
- !include jobs/job1.yaml

# ....
```

Which allows managing resources in individual files (e.g. using a friendly directory structure), and still being able to import with `awx import -f yaml < resources.yaml`.

#### SUGGESTED IMPLEMENTATION

Use `awxkit.yaml_file.Loader` instead of `yaml.safe_load` in https://github.com/ansible/awx/blob/devel/awxkit/awxkit/cli/resource.py#L143




Discussion:

Resolving patch:
diff --git a/awxkit/awxkit/cli/resource.py b/awxkit/awxkit/cli/resource.py
--- a/awxkit/awxkit/cli/resource.py
+++ b/awxkit/awxkit/cli/resource.py
@@ -2,7 +2,7 @@
 import json
 import os
 
-from awxkit import api, config
+from awxkit import api, config, yaml_file
 from awxkit.exceptions import ImportExportError
 from awxkit.utils import to_str
 from awxkit.api.pages import Page
@@ -140,7 +140,7 @@ def handle(self, client, parser):
         if fmt == 'json':
             data = json.load(client.stdin)
         elif fmt == 'yaml':
-            data = yaml.safe_load(client.stdin)
+            data = yaml.load(client.stdin, Loader=yaml_file.Loader)
         else:
             raise ImportExportError("Unsupported format for Import: " + fmt)
 


Test patch:
diff --git a/awxkit/test/cli/test_format.py b/awxkit/test/cli/test_format.py
--- a/awxkit/test/cli/test_format.py
+++ b/awxkit/test/cli/test_format.py
@@ -63,6 +63,7 @@ def _dummy_authenticate():
           - name: Workflow1
         """
     )
+    yaml_fd.name = 'file.yaml'
     cli = CLI(stdin=yaml_fd)
     cli.parse_args(['--conf.format', 'yaml'])
     cli.v2 = MockedV2()
Repository: ansible/awx

Issue:
awx.awx.tower not working with null groups
##### ISSUE TYPE
 - Bug Report

##### ENVIRONMENT
* AWX version: 15.0.0
* AWX install method: docker on linux
* Ansible version:  2.9.13
* Operating System: macOS

##### STEPS TO REPRODUCE
Try parse inventory from cli where some groups has no any hosts
 ```
ansible-inventory -i inventory_tower/test_awx_tower.yml --graph
[WARNING]: You are running collection version 15.0.1 but connecting to tower version 15.0.0
@all:
  |--@test_group1:
  |  |--@test_group2:
  |  |  |--test_host_1
  |  |--test_host_1
  |--@ungrouped:
```
if remove test_host1 from test_group2
```
ansible-inventory -i inventory_tower/test_awx_tower.yml --graph
[WARNING]: You are running collection version 15.0.1 but connecting to tower version 15.0.0
[WARNING]:  * Failed to parse /Users/meonacist/playbook/inventory_tower/test_awx_tower.yml with auto plugin: test_group2 is not a known host nor group
[WARNING]:  * Failed to parse /Users/meonacist/playbook/inventory_tower/test_awx_tower.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /Users/meonacist/playbook/inventory_tower/test_awx_tower.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this
character is reserved to provide a port.
[WARNING]: Unable to parse /Users/meonacist/playbook/inventory_tower/test_awx_tower.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:
```
cat inventory_tower/test_awx_tower.yml
```
plugin: awx.awx.tower
host: awx.local.lan
inventory_id: 58
validate_certs: no
include_metadata: yes
```

<!-- Please describe exactly how to reproduce the problem. -->

##### EXPECTED RESULTS
 ```
ansible-inventory -i inventory_tower/test_awx_tower.yml --graph
[WARNING]: You are running collection version 15.0.1 but connecting to tower version 15.0.0
@all:
  |--@test_group1:
  |  |--@test_group2:
  |  |--test_host_1
  |--@ungrouped:
```



Discussion:

Resolving patch:
diff --git a/awx_collection/plugins/inventory/tower.py b/awx_collection/plugins/inventory/tower.py
--- a/awx_collection/plugins/inventory/tower.py
+++ b/awx_collection/plugins/inventory/tower.py
@@ -153,6 +153,8 @@ def parse(self, inventory, loader, path, cache=True):
                     self.inventory.add_host(host_name, group_name)
                 # Then add the parent-children group relationships.
                 for child_group_name in group_content.get('children', []):
+                    # add the child group to groups, if its already there it will just throw a warning
+                    self.inventory.add_group(child_group_name)
                     self.inventory.add_child(group_name, child_group_name)
             # Set the group vars. Note we should set group var for 'all', but not '_meta'.
             if group_name != '_meta':


Test patch:
Repository: ansible/awx

Issue:
Advanced search for type returns 400
<!-- Issues are for **concrete, actionable bugs and feature requests** only - if you're just asking for debugging help or technical support, please use:

- http://webchat.freenode.net/?channels=ansible-awx
- https://groups.google.com/forum/#!forum/awx-project

We have to limit this because of limited volunteer time to respond to issues! -->

##### ISSUE TYPE
 - Bug Report

##### SUMMARY

Trying to do an advanced search by `type` the results are always `ExecutionEnvironment has no field named 'type'`:

![image](https://user-images.githubusercontent.com/12464858/109544586-83d70a00-7aa6-11eb-994c-dedcbce8801a.png)





Discussion:
This is not just an issue with EE.  It seems like we will need to re-evaluate the `type` search for other resources as well. See Organization.

<img width="1451" alt="image" src="https://user-images.githubusercontent.com/9053044/109999983-cc7a0780-7ce0-11eb-8666-9433085a2d2b.png">

Lets look and see if this is a dupe
Related: https://github.com/ansible/awx/issues/8480

Resolving patch:
diff --git a/awx/api/metadata.py b/awx/api/metadata.py
--- a/awx/api/metadata.py
+++ b/awx/api/metadata.py
@@ -26,6 +26,9 @@
 from awx.main.models import NotificationTemplate
 from awx.main.tasks import AWXReceptorJob
 
+# Polymorphic
+from polymorphic.models import PolymorphicModel
+
 
 class Metadata(metadata.SimpleMetadata):
     def get_field_info(self, field):
@@ -78,7 +81,9 @@ def get_field_info(self, field):
                 field_info['help_text'] = field_help_text[field.field_name].format(verbose_name)
 
             if field.field_name == 'type':
-                field_info['filterable'] = True
+                # Only include model classes with `type` field.
+                if issubclass(serializer.Meta.model, PolymorphicModel):
+                    field_info['filterable'] = True
             else:
                 for model_field in serializer.Meta.model._meta.fields:
                     if field.field_name == model_field.name:


Test patch:
Repository: ansible/awx

Issue:
improve job launch failed error when due to content signature validation failure
### Please confirm the following

- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.

### Feature Summary

As a user I want to be able to see succinct and informative messaging in the event that content signature validation fails. This failure will reside in the job failure messaging and will be the same output for UI, API, and CLI.

Also update what we are calling task (right now says project integrity  vs Content Signature Validation. This nomenclature needs to be updated.)


### Select the relevant components

- [X] UI
- [X] API
- [ ] Docs
- [ ] Collection
- [X] CLI
- [ ] Other



![Image](https://user-images.githubusercontent.com/89486372/185957319-9d8d56dc-e975-4b25-a442-f55bced740c3.png)




Discussion:

Resolving patch:
diff --git a/awx/api/serializers.py b/awx/api/serializers.py
--- a/awx/api/serializers.py
+++ b/awx/api/serializers.py
@@ -4197,6 +4197,15 @@ def validate(self, attrs):
         elif template.project.status in ('error', 'failed'):
             errors['playbook'] = _("Missing a revision to run due to failed project update.")
 
+            latest_update = template.project.project_updates.last()
+            if latest_update is not None and latest_update.failed:
+                failed_validation_tasks = latest_update.project_update_events.filter(
+                    event='runner_on_failed',
+                    play="Perform project signature/checksum verification",
+                )
+                if failed_validation_tasks:
+                    errors['playbook'] = _("Last project update failed due to signature validation failure.")
+
         # cannot run a playbook without an inventory
         if template.inventory and template.inventory.pending_deletion is True:
             errors['inventory'] = _("The inventory associated with this Job Template is being deleted.")


Test patch:
Repository: ansible/awx

Issue:
Token and Session Expiration never run after the first time
### Please confirm the following

- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.

### Bug Summary

Looks like when we implemented token and session cleanup way back in https://github.com/ansible/awx/pull/3856

We populated the recurrence rule incorrectly:

https://github.com/ansible/awx/blob/8a06ffbe15c9f8e68b1da86e5ca7daf5ecfd6da4/awx/main/migrations/_create_system_jobs.py#L39

This schedule will only ever run once due to `COUNT=1`.... we should omit that so that it will periodically run.

### AWX version

latest

### Select the relevant components

- [ ] UI
- [X] API
- [ ] Docs
- [ ] Collection
- [ ] CLI
- [ ] Other

### Installation method

minishift

### Modifications

no

### Ansible version

_No response_

### Operating system

_No response_

### Web browser

_No response_

### Steps to reproduce

install awx

### Expected results

periodic running of these management jobs

### Actual results

the jobs only run once

### Additional information

_No response_


Discussion:

Resolving patch:
diff --git a/awx/main/migrations/_create_system_jobs.py b/awx/main/migrations/_create_system_jobs.py
--- a/awx/main/migrations/_create_system_jobs.py
+++ b/awx/main/migrations/_create_system_jobs.py
@@ -36,7 +36,7 @@ def create_clearsessions_jt(apps, schema_editor):
     if created:
         sched = Schedule(
             name='Cleanup Expired Sessions',
-            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
+            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,
             description='Cleans out expired browser sessions',
             enabled=True,
             created=now_dt,
@@ -69,7 +69,7 @@ def create_cleartokens_jt(apps, schema_editor):
     if created:
         sched = Schedule(
             name='Cleanup Expired OAuth 2 Tokens',
-            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1' % schedule_time,
+            rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1' % schedule_time,
             description='Removes expired OAuth 2 access and refresh tokens',
             enabled=True,
             created=now_dt,


Test patch:
Repository: ansible/awx

Issue:
CyberArk Conjur Secret Lookup - Versioning Does Not Work
### Please confirm the following

- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.

### Bug Summary

When providing a version number on the "Metadata" section of the CyberArk Conjur Secret Lookup External Secret Management System pane when defining a secret to retrieve on a credential, the secret value associated with the version number is not returned during execution of the job.  Regardless of the version number given, only the latest secret value is ever returned.

### AWX version

Ansible Automation Platform Controller 4.1.1

### Select the relevant components

- [ ] UI
- [ ] API
- [ ] Docs
- [ ] Collection
- [ ] CLI
- [X] Other

### Installation method

N/A

### Modifications

no

### Ansible version

ansible [core 2.12.2]

### Operating system

Red Hat Enterprise Linux release 8.6 (Ootpa)

### Web browser

_No response_

### Steps to reproduce

1. Configure CyberArk Conjur Secret Lookup.
2. Configure Credential to use External Secret Management System.
3. On Metadata, provide a version number not equal to `null` or `1`.
4. Run a job to execute a playbook that has `debug.msg` print the value to STDOUT.

### Expected results

The value returned should change based on the version being requested by the External Secret Management System metadata.

### Actual results

The latest version of the secret is always returned and versioning is ignored.

### Additional information

![image](https://user-images.githubusercontent.com/1924063/188949257-37a35059-82a2-4beb-8864-45f84466accd.png)



Discussion:
Hello,
Based on the version you have provided it sounds like you are using Controller, rather than AWX. We would recommend that you reach out to Red Hat support. 
@djyasin,

You are correct, however this issue also persists in AWX.  I just happened to do my testing using Ansible Automation Platform.  Shall I modify the issue for AWX or open a new issue for it?
I should also note that I am not a customer of Red Hat, but a partner as I'm employed by CyberArk.  I'm happy to assist any way I can with resolving this issue.

Resolving patch:
diff --git a/awx/main/credential_plugins/conjur.py b/awx/main/credential_plugins/conjur.py
--- a/awx/main/credential_plugins/conjur.py
+++ b/awx/main/credential_plugins/conjur.py
@@ -81,7 +81,8 @@ def conjur_backend(**kwargs):
     # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get
     path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))
     if version:
-        path = '?'.join([path, version])
+        ver = "version={}".format(version)
+        path = '?'.join([path, ver])
 
     with CertFiles(cacert) as cert:
         lookup_kwargs['verify'] = cert


Test patch: