Azure-cli: [cache]`cache show` fails with stack trace if resource type is not specified

Created on 24 Apr 2019  路  7Comments  路  Source: Azure/azure-cli

This is autogenerated. Please review and update as needed.

Describe the bug

az cache show -n {} -g {} fails...
az cache show -n {} -g {} -t {} succeeds...

Command Name
az cache show

Errors:

join() argument must be str or bytes, not 'NoneType'
Traceback (most recent call last):
python3.7/site-packages/knack/cli.py, ln 206, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 523, in execute
    raise ex
cli/core/commands/__init__.py, ln 581, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 574, in _run_job
    six.reraise(*sys.exc_info())
...
cli/command_modules/configure/custom.py, ln 194, in show_cache_contents
    item_path = os.path.join(directory, resource_group_name, resource_type, '{}.json'.format(item_name))
../lib/python3.7/posixpath.py, ln 94, in join
    genericpath._check_arg_types('join', a, *p)
../lib/python3.7/genericpath.py, ln 149, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • _Put any pre-requisite steps here..._
  • az cache show -n {} -g {}

Expected Behavior

Environment Summary

Darwin-18.0.0-x86_64-i386-64bit
Python 3.7.3
Shell: bash

azure-cli 2.0.62 *

Extensions:
dev-spaces 1.0.0
alias 0.5.2
interactive 0.4.2

Additional Context


Core bug

All 7 comments

@tjprescott Full stack trace:

The command failed with an unexpected error. Here is the traceback:

join() argument must be str or bytes, not 'NoneType'
Traceback (most recent call last):
  File "/Users/tosin/Repos/cli-venv/lib/python3.7/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py", line 523, in execute
    raise ex
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py", line 581, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py", line 574, in _run_job
    six.reraise(*sys.exc_info())
  File "/Users/tosin/Repos/cli-venv/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py", line 551, in _run_job
    result = cmd_copy(params)
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py", line 289, in __call__
    return self.handler(*args, **kwargs)
  File "/Users/tosin/Repos/azure-cli/src/azure-cli-core/azure/cli/core/__init__.py", line 453, in default_command_handler
    return op(**command_args)
  File "/Users/tosin/Repos/azure-cli/src/command_modules/azure-cli-configure/azure/cli/command_modules/configure/custom.py", line 194, in show_cache_contents
    item_path = os.path.join(directory, resource_group_name, resource_type, '{}.json'.format(item_name))
  File "/Users/tosin/Repos/cli-venv/bin/../lib/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  File "/Users/tosin/Repos/cli-venv/bin/../lib/python3.7/genericpath.py", line 149, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

All three arguments should be required. Thanks for the report.

@tjprescott I also add two other issues:

  • cli_ctx.data['_cache'] is persisted between self.cmd() calls in scenariotests.
  • cacheObject.result() fails when the model is not in a API-versioned sdk.

cli_ctx.data['_cache'] is persisted between self.cmd() calls in scenariotests.

Yes, I found the same and that is fixed.

cacheObject.result() fails when the model is not in a API-versioned sdk.

What error do you get?

@tjprescott. Nice to hear it was fixed. I would pull in dev into my branch.

Below is the error I got:


src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/tests/latest/test_image_builder_commands.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/azure-cli-testsdk/azure/cli/testsdk/base.py:161: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:199: in __init__
    self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:262: in _in_process_execute
    raise ex.exception
../cli-venv/lib/python3.7/site-packages/knack/cli.py:206: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/__init__.py:523: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/__init__.py:581: in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/__init__.py:574: in _run_job
    six.reraise(*sys.exc_info())
../cli-venv/lib/python3.7/site-packages/six.py:693: in reraise
    raise value
src/azure-cli-core/azure/cli/core/commands/__init__.py:551: in _run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/__init__.py:289: in __call__
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/__init__.py:453: in default_command_handler
    return op(**command_args)
src/command_modules/azure-cli-vm/azure/cli/command_modules/vm/_image_builder.py:418: in add_template_output
    existing_image_template = cached_get(cmd, client.virtual_machine_image_templates.get, resource_group_name, image_template_name)
src/azure-cli-core/azure/cli/core/commands/__init__.py:350: in cached_get
    cache_obj.load(args, kwargs)
src/azure-cli-core/azure/cli/core/commands/__init__.py:203: in load
    self._payload = self.result()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <azure.cli.core.commands.CacheObject object at 0x109ed7780>

    def result(self):
        model_cls = self._cmd.get_models(self._model_type)
>       return model_cls.deserialize(self._payload)
E       AttributeError: 'NoneType' object has no attribute 'deserialize'

src/azure-cli-core/azure/cli/core/commands/__init__.py:218: AttributeError
----------------------------------------------- generated xml file: /Users/tosin/.azdev/env_config/Users/tosin/Repos/cli-venv/test_results.xml -

I believe model_cls is None because get_models only works on versioned models.

cli_ctx.data['_cache'] is persisted between self.cmd() calls in scenariotests.

Yes, I found the same and that is fixed.

Has the fix been merged to dev? I am still having this issue. Or is this in your current pr

It is in the PR.

Was this page helpful?
0 / 5 - 0 ratings