Azure / Azure/azure-cli

Incorrect arguments parsing when `-` is the first character

Open
#19,644 11 comments 1 reaction 1 assignee Claimed by @oncerune View on GitHub
act-observability-squad customer-reported Functions Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## Describe the bug

Incorrect args parsing when arg value contains `-` as first character, for example `-value`.

**Command Name**
```
az functionapp keys set --key-value "-asd"
# ^ incriminated
```

**Errors:**
```
az functionapp keys set --key-value -KeyValue --key-name -KeyName --name test-function-abc --resource-group test-rg --key-type functionKeys
argument --key-value: expected one argument

# Or in arg key-name

az functionapp keys set --key-value KeyValue --key-name -KeyName --name test-function-abc --resource-group test-rg --key-type functionKeys
argument --key-name: expected one argument

# With "escaped" values

az functionapp keys set --key-value "-KeyValue" --key-name "-KeyName" --name test-function-abc --resource-group test-rg --key-type functionKeys
argument --key-value: expected one argument
```

## To Reproduce:

- Create a function app named `test-function` on resource-group `test-rg`
- For reference a `Node.js` runtime was selected in `westeurope`
- Run one of the command above (eg. `key-value` or `key-name` must include an arg value with `-Something`)

## Expected Behavior

An Host Key should be succesfully created with the provided correct `-Something` value.

## Environment Summary
```
Linux-5.10.43.3-microsoft-standard-WSL2-x86_64-with-debian-bullseye-sid, Ubuntu 20.04.3 LTS
Python 3.6.10
Installer: DEB

azure-cli 2.28.0

```
## Additional Context

The same happen when using `az functionapp function keys set`.

```
az functionapp function keys set --key-name "-KeyName" --key-value "-KeyValue" --function-name test-fn-http --name test-function-abc --resource-group test-rg
argument --key-name: expected one argument
```

There is not problem with `-` in the middle of the arg value, for example:

```
az functionapp function keys set --key-name "Key-Name" --key-value "Key-Value" --function-name test-fn-http --name test-function-abc --resource-group test-rg
Location Name ResourceGroup Value
----------- -------- --------------- ---------
West Europe Key-Name test-rg Key-Value
```

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.