Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API allows non-option to be default in multiselect and multipechoice surveys #4452

Closed
IPvSean opened this issue Aug 9, 2019 · 5 comments
Closed

Comments

@IPvSean
Copy link
Contributor

IPvSean commented Aug 9, 2019

ISSUE TYPE
  • Bug Report
SUMMARY

I am creating a very simple 4 node workflow. One of the Job Templates is auto-populated

    - name: CREATE RESTORE JOB TEMPLATE
      tower_job_template:
        name: "Network-Restore"
        job_type: "run"
        inventory: "Workshop Inventory"
        project: "Workshop Project"
        playbook: "network_restore.yml"
        credential: "Workshop Credential"
        survey_enabled: true
        survey_spec: "{{ lookup('template', '{{playbook_dir}}/templates/backup.j2') }}"
        tower_username: admin
        tower_password: ansible
        tower_host: "https://{{ansible_fqdn}}"
        validate_certs: no

here is the backup.j2 template referenced above for the survey_spec->
https://github.com/network-automation/tower_workshop/blob/master/templates/backup.j2

ENVIRONMENT

Tower 3.5.1

STEPS TO REPRODUCE

I am doing this exact exercise here: https://github.com/ansible/workshops/tree/devel/exercises/ansible_network/9-tower-workflow

EXPECTED RESULTS

Would force me to choose a prompt during the selection process for the Network-Restore Job Template

ACTUAL RESULTS

error message with no details

undefined error

ADDITIONAL INFORMATION

more info coming

@chrismeyersfsu
Copy link
Member

Steps to reproduce

  • Create a JT w/ a survey w/ a multichoice (single select) field & a default answer.
  • Go to that JT survey in the API & set the default answer to something not in the multichoice list
{
    "name": "",
    "description": "",
    "spec": [
        {
            "question_name": "This is a prompt",
            "question_description": "",
            "required": true,
            "type": "multiplechoice",
            "variable": "dfdsfd",
            "min": null,
            "max": null,
            "default": "foobar",
            "choices": "test\ntest2\ntest3"
        }
    ]
}
  • Now create a workflow and use that JT and get the ERROR

@rebeccahhh
Copy link
Member

Correct template link

@rebeccahhh
Copy link
Member

rebeccahhh commented Sep 17, 2019

When posting the API I seem to be getting the same issue as the UI has in #4192 and #4343
The /n in the given example is being ignored and when checking in the UI there is only 1 option, the string "test\ntest2\ntest3"
update: as stated in the issue linked above, this is intermittent and does not persist.

@rebeccahhh
Copy link
Member

rebeccahhh commented Sep 30, 2019

The UI does not allow anything other than existing options to be the default choice in a survey, but the API does.

API:
image

Posted in the API means the UI now shows:
image

Upon trying to do the same in the UI, it throws the appropriate error:
image

@kdelee kdelee self-assigned this Jan 2, 2020
@kdelee kdelee changed the title Doesn't force user to fill out prompt (survey) in Workflow ~Doesn't force user to fill out prompt (survey) in Workflow~ API allows non-option to be default in multiselect and multipechoice surveys Jan 2, 2020
@kdelee kdelee changed the title ~Doesn't force user to fill out prompt (survey) in Workflow~ API allows non-option to be default in multiselect and multipechoice surveys API allows non-option to be default in multiselect and multipechoice surveys Jan 2, 2020
@kdelee
Copy link
Member

kdelee commented Jan 2, 2020

Tested this out, you can no longer POST a survey spec w/ a default that is not an option, which was root cause of this bug.

Closing

Screenshot from 2020-01-02 16-56-03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants