microsoft / microsoft/knack

Knack error when I run azdev linter

Open
#243 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
358
Forks
101
PR merge metrics
No merged PRs in 30d

Description

A weird error when I run azdev linter

cli.knack.cli: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
  File "c:\users\yfy\work\env\lib\site-packages\knack\cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "c:\users\yfy\work\env\lib\site-packages\knack\invocation.py", line 225, in execute
    cmd_result = parsed_args.func(params)
  File "c:\users\yfy\work\env\lib\site-packages\knack\commands.py", line 148, in __call__
    return self.handler(*args, **kwargs)
  File "c:\users\yfy\work\env\lib\site-packages\knack\commands.py", line 255, in _command_handler
    result = op(client, **command_args) if client else op(**command_args)
  File "c:\users\yfy\work\azure-cli-dev-tools\azdev\operations\linter\__init__.py", line 118, in run_linter
    create_invoker_and_load_cmds_and_args(az_cli)
  File "c:\users\yfy\work\azure-cli\src\azure-cli-core\azure\cli\core\file_util.py", line 76, in create_invoker_and_load_cmds_and_args
    invoker.commands_loader.load_arguments()
  File "c:\users\yfy\work\azure-cli\src\azure-cli-core\azure\cli\core\__init__.py", line 490, in load_arguments
    c.argument('resource_group_name', resource_group_name_type)
  File "c:\users\yfy\work\azure-cli\src\azure-cli-core\azure\cli\core\commands\parameters.py", line 371, in argument
    if not self._applicable():
  File "c:\users\yfy\work\env\lib\site-packages\knack\arguments.py", line 153, in _applicable
    return self.command_loader.cli_ctx.invocation.data['command_string'].startswith(self.command_scope)
AttributeError: 'NoneType' object has no attribute 'startswith'

Version
knack, 0.8.0rc2
azdev, 0.1.29

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce azdev linter, then start at knack/arguments.py in _applicable() and follow the command_string value through the knack invocation path. The traceback also points to azure/cli/core/file_util.py, azure/cli/core/__init__.py, and azure/cli/core/commands/parameters.py; done means the linter no longer raises this NoneType error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.