ansible / galaxy_collection

Collection of modules and roles to configure Automation Hub
GNU General Public License v3.0
58 stars 54 forks source link

Better error message when incorrect Private Hub credentials specified #353

Open kk-at-redhat opened 10 months ago

kk-at-redhat commented 10 months ago

Summary

Show meaningful error message when Private Hub credentials are incorrect.

Issue Type

Ansible, Collection, Private Automation Hub details

ansible --version
ansible [core 2.14.2]
  config file = None
  configured module search path = ['/home/kk/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/kk/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

ansible-galaxy collection list
Collection             Version
---------------------- -------
ansible.controller     4.4.7
awx.awx                23.2.0
infra.ah_configuration 2.0.4

Private Automation Hub version
Server version 4.6.3
Pulp Ansible Version 0.15.0
UI Version 4.6.3

OS / ENVIRONMENT

Red Hat Enterprise Linux release 9.1 (Plow)

Desired Behavior

Meaningful error message, for example: "Unable to log in to Private Automation Hub", or perhaps "Failed to authenticate", or "Incorrect username or password"

Actual Behavior

Getting the following error: "An unhandled exception occurred while running the lookup plugin 'infra.ah_configuration.ah_api'. Error was a <class 'TypeError'>, original message: expected string or bytes-like object. expected string or bytes-like object"

STEPS TO REPRODUCE

Make query via API like so:

- name: Get list of published collections
  ansible.builtin.set_fact:
    published_collections: "{{ query('infra.ah_configuration.ah_api',
                                     'collections',
                                      host=hub_config_host,
                                      username=hub_config_user,
                                      password=hub_config_pass,
                                      verify_ssl=false) }}"

specifying incorrect credentials in hub_config_user/hub_config_pass.

Get an error message that doesn't make any sense:

{
  "msg": "An unhandled exception occurred while running the lookup plugin 'infra.ah_configuration.ah_api'. Error was a <class 'TypeError'>, original message: expected string or bytes-like object. expected string or bytes-like object",
  "_ansible_no_log": false
}