ansible / mazer

Experimental Ansible Galaxy Content Manager
GNU General Public License v3.0
113 stars 18 forks source link

mazer version fails from pypi? #283

Closed alikins closed 5 years ago

alikins commented 5 years ago

I just downloaded the latest version of mazer using pip and I’m getting this error

'NoneType' object has no attribute 'copy'
Traceback (most recent call last):
  File "/Users/dnewswan/code/venv/mazer/bin/mazer", line 10, in <module>
    sys.exit(main())
  File "/Users/dnewswan/code/venv/mazer/lib/python3.6/site-packages/ansible_galaxy_cli/main.py", line 36, in main
    exit_code = cli.run()
  File "/Users/dnewswan/code/venv/mazer/lib/python3.6/site-packages/ansible_galaxy_cli/cli/galaxy.py", line 221, in run
    galaxy_context = self._get_galaxy_context(self.options, self.config)
  File "/Users/dnewswan/code/venv/mazer/lib/python3.6/site-packages/ansible_galaxy_cli/cli/galaxy.py", line 188, in _get_galaxy_context
    server = config.server.copy()
AttributeError: 'NoneType' object has no attribute 'copy'```

can’t even check the version

Bug Report

MAZER VERSION
CONFIGURATION
ironfroggy commented 5 years ago

@alikins I think David got this problem when trying to install Mazer while an invalid config was present. I'll try to reproduce the problem myself, but it looks the same from his previous report.

alikins commented 5 years ago

@ironfroggy previous report? I didn't see anything in issues.

ironfroggy commented 5 years ago

It was reported in chat, it doesn't look like he filed an issue. My apologies for not following up on the issue sooner.

On Tue, Jun 11, 2019 at 9:30 AM Adrian Likins notifications@github.com wrote:

@ironfroggy https://github.com/ironfroggy previous report? I didn't see anything in issues.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ansible/mazer/issues/283?email_source=notifications&email_token=AAAIRJX6MYWDYQ3STEFC2KTPZ6SFPA5CNFSM4HWTYVRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNDZAA#issuecomment-500841600, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAIRJTCOEXE6PA4KWVAOQTPZ6SFPANCNFSM4HWTYVRA .

--

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma@redhat.com M: +1.336.210.5107 [image: https://red.ht/sig] https://red.ht/sig TRIED. TESTED. TRUSTED. https://redhat.com/trusted

ironfroggy commented 5 years ago

I haven't been able to reproduce this myself, no matter how I formulate a config file.

alikins commented 5 years ago

I can reproduce with a config file that has no value for the rhs of 'server', like this:

server:
  # ignore_certs: false
  # url: https://galaxy-qa.ansible.com
  # api_key: 0c6973571301ce1f3b08c27978e3f50a057157b8

collections_path: ~/.ansible/collections/
global_collections_path: /usr/share/ansible/collections/
(mazer_0.4.0_py36) [newswoop:F29:mazer (mazer_config_broke %)]$ mazer --config server_none_mazer_config.yml version
ERROR| 'NoneType' object has no attribute 'copy'
Traceback (most recent call last):
  File "/home/adrian/venvs/mazer_0.4.0_py36/bin/mazer", line 11, in <module>
    load_entry_point('mazer', 'console_scripts', 'mazer')()
  File "/home/adrian/src/mazer/ansible_galaxy_cli/main.py", line 36, in main
    exit_code = cli.run()
  File "/home/adrian/src/mazer/ansible_galaxy_cli/cli/galaxy.py", line 221, in run
    galaxy_context = self._get_galaxy_context(self.options, self.config)
  File "/home/adrian/src/mazer/ansible_galaxy_cli/cli/galaxy.py", line 188, in _get_galaxy_context
    server = config.server.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
alikins commented 5 years ago

Currently in the app itself, the config object is never persisted/saved to a file, so the copy() isn't really.

At the moment there is not much validation of the config object or the data from yaml loading (pretty much just ensures that any required attributes exist, but not their value).

The config class could be replaced with an attrs based class, with some validators. Or some more adhoc validation in ansible_galaxy.config.load().

Since the config as is probably won't survive the transplant to ansible-galaxy, I'll just make sure it raises a GalaxyConfigFileError in that case.