Azure / Azure/azure-devops-cli-extension

[Bug] Cannot run "az devops invoke" with --in-fille different than json

Open
#1,010 0 comments 3 reactions 0 assignees View on GitHub
Area: ProToCol bug
Dominant language
Python
Stars
682
Forks
278
Avg merge
3d 23h
Merged PRs (30d)
3

Description

**Describe the bug**
No way to upload secure files using az devops invoke command. --in-fille expects only json, where secure file in the library can be different.

az devops invoke --api-version "5.0" --area distributedtask --resource securefiles --organization "https://dev.azure.com/myorg" --http-method POST --media-type "application/octet-stream" --route-parameters project=myproject --in-file "dev.env"

**To Reproduce**
Azure Cli Version: 2.6.0
Azure-Devops extension version: 0.18.0

Steps to reproduce the behavior:
az devops invoke --api-version "5.0" --area distributedtask --resource securefiles --organization "https://dev.azure.com/myorg" --http-method POST --media-type "application/octet-stream" --route-parameters project=myproject --in-file "dev.env"

**Expected behavior**
Secure file is uploaded.
If --media-type is different than application/json than --in-file can be different type.

**Debug logs**
cli.azure.cli.core.util : Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 215, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 709, in _run_job
cmd_copy.exception_handler(ex)
File "/home/daporo/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 31, in azure_devops_exception_handler
reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 688, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 325, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 545, in default_command_handler
return op(**command_args)
File "/home/daporo/.azure/cliextensions/azure-devops/azext_devops/dev/team/invoke.py", line 44, in invoke
request_body = json.loads(in_file_content)
File "/opt/az/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/opt/az/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/az/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 215, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 709, in _run_job
cmd_copy.exception_handler(ex)
File "/home/daporo/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 31, in azure_devops_exception_handler
reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 688, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 325, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 545, in default_command_handler
return op(**command_args)
File "/home/daporo/.azure/cliextensions/azure-devops/azext_devops/dev/team/invoke.py", line 44, in invoke
request_body = json.loads(in_file_content)
File "/opt/az/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/opt/az/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/az/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

**Additional context**
Under https://github.com/Azure/azure-devops-cli-extension/blob/master/azure-devops/azext_devops/dev/team/invoke.py#L37 expects --in-file to be json only, but in some scenarios is not the case.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.