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

[BUG] namecheap module: Passed invalid arguments to namecheap_<module>.<function>: must be str, not NoneType #61209

Open
1 task done
ggiesen opened this issue Nov 10, 2021 · 0 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior

Comments

@ggiesen
Copy link
Contributor

ggiesen commented Nov 10, 2021

Description
When using any of the namecheap execution modules, I receive the following error:

Passed invalid arguments to namecheap_<module>.<function>: must be str, not NoneType

Example with namecheap_users.check_balances:

INFO    ] User root Executing command namecheap_users.check_balances with jid 20211110005553905719
[DEBUG   ] Command details {'fun': 'namecheap_users.check_balances', 'arg': [], 'tgt': 'salt01', 'jid': '20211110005553905719', 'ret': '', 'tgt_type': 'glob', 'user': 'root'}
[DEBUG   ] Subprocess ProcessPayload-Job-20211110005553905719 added
[DEBUG   ] Using importlib_metadata to load entry points
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[INFO    ] Starting a new job 20211110005553905719 with PID 832773
[DEBUG   ] Could not LazyLoad direct_call.allow_missing_func: 'direct_call.allow_missing_func' is not available.
[DEBUG   ] LazyLoaded namecheap_users.check_balances
[WARNING ] Passed invalid arguments to namecheap_users.check_balances: 'NoneType' object is not subscriptable

    Checks if the provided minimum value is present in the user's account.

    Returns a boolean. Returns ``False`` if the user's account balance is less
    than the provided minimum or ``True`` if greater than the minimum.

    minimum : 100
        The value to check

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_users.check_balances
        salt 'my-minion' namecheap_users.check_balances minimum=150


Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1912, in _thread_return
    function_name, function_args, executors, opts, data
  File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1868, in _execute_job_function
    return_data = self.executors[fname](opts, data, func, args, kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 10, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/namecheap_users.py", line 94, in check_balances
    result = get_balances()
  File "/usr/lib/python3.6/site-packages/salt/modules/namecheap_users.py", line 64, in get_balances
    opts = salt.utils.namecheap.get_opts("namecheap.users.getBalances")
  File "/usr/lib/python3.6/site-packages/salt/utils/namecheap.py", line 156, in get_opts
    opts["ApiUser"] = __salt__["config.option"]("namecheap.name")
TypeError: 'NoneType' object is not subscriptable
[DEBUG   ] Minion return retry timer set to 5 seconds (randomized)
[INFO    ] Returning information for job: 20211110005553905719
[DEBUG   ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'salt01', 'tcp://127.0.0.1:4506')
[DEBUG   ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.0.1:4506
[DEBUG   ] Trying to connect to: tcp://127.0.0.1:4506
[DEBUG   ] Closing AsyncZeroMQReqChannel instance
[DEBUG   ] minion return: {'success': False, 'return': "Passed invalid arguments to namecheap_users.check_balances: 'NoneType' object is not subscriptable\n\n    Checks 
if the provided minimum value is present in the user's account.\n\n    Returns a boolean. Returns ``False`` if the user's account balance is less\n    than the provided 
minimum or ``True`` if greater than the minimum.\n\n    minimum : 100\n        The value to check\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt 'my-minion' namecheap_users.check_balances\n        salt 'my-minion' namecheap_users.check_balances minimum=150\n\n    ", 'out': 'nested', 'retcode': 1, 'jid': '20211110005553905719', 'fun': 'namecheap_users.check_balances', 'fun_args': []}

It looks like the __salt__ dunder is set to None in utils/namecheap.py (and not subsequently set), and as such it can't read the config.

Setup
/etc/salt/minion.d/namecheap.conf:

namecheap.name: cheapuser
namecheap.key: aid3ofietaizie0quaeNgutheY8uzeim
namecheap.client_ip: 192.0.2.1
namecheap.url: https://api.namecheap.com/xml.response

Please be as specific as possible and give set-up details.

  • VM (Virtualbox, KVM, etc. please specify)

AlmaLinux 8 VM on VMware vSphere 7.0. Minion is running on same host as master.

Steps to Reproduce the behavior

  1. $ salt minion namecheap_users.check_balances

Expected behavior
Return whether the account balance exceeds $100

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: 1.11.5
      cherrypy: unknown
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: 0.26.8
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.14
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: 0.26.4
        Python: 3.6.8 (default, Sep 23 2021, 07:23:00)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: almalinux 8.4 Electric Cheetah
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-305.19.1.el8_4.x86_64
        system: Linux
       version: AlmaLinux 8.4 Electric Cheetah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants