ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.86k stars 3.4k forks source link

Default value for webhook_service is not listed #7374

Open sumkincpp opened 4 years ago

sumkincpp commented 4 years ago
ISSUE TYPE
SUMMARY

Related to #5099

Current OPTIONS for job_templates output doesn't have default listed as "default": "" for webhook_service, which have required: false.

Default is expected to be listed within the API since it is not required -

            "webhook_service": {
                "type": "choice",
                "required": false,
                "label": "Webhook service",
                "help_text": "Service that webhook requests will be accepted from",
                "filterable": true,
                "choices": [
                    [
                        "",
                        "---------"
                    ],
                    [
                        "github",
                        "GitHub"
                    ],
                    [
                        "gitlab",
                        "GitLab"
                    ]
                ]
            },
ENVIRONMENT

AWX version: 11.2.0 AWX install method: N/A Ansible version: N/A Operating System: Web Browser:

blomquisg commented 4 years ago

@ryanpetrello can you weigh in on this?

ryanpetrello commented 4 years ago

Nope, I'm not familiar with the change that affected this cc @AlanCoding @jbradberry @elyezer

jbradberry commented 4 years ago

This skip field behavior is coming from Django REST Framework itself, and thus this piece of metadata should be missing on all of our fields that have an empty default since we aren't overriding it anywhere.

https://github.com/ansible/awx/blob/a26df3135b73290951c45a2a3903849517a44c72/awx/api/metadata.py#L88-L96

https://github.com/encode/django-rest-framework/blob/aed74961ba03e3e6f53c468353f4e255eb788555/rest_framework/fields.py#L501-L503

jbradberry commented 4 years ago

This looks easy enough to fix if we want this change, but it will affect all currently skipped fields, not just webhook_service.

I take that back, ultimately the field itself is refusing to return a value when get_default is called on it.