`az config set` with a bad value leaves config file in an unrecoverable state
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
1. I accidentally ran the following:
```sh
az config set logging.enable_log_file=~/az-logs
```
The command was accepted without any errors.
1. I then realized I'd set it incorrectly and tried to correct it with:
```sh
az config set logging.enable_log_file=true
```
However, I now see the following exception, and I'm unable to change the value or modify any other config settings:
```
C:\Users\antmarti>az config set logging.enable_log_file=true
Traceback (most recent call last):
File "runpy.py", line 194, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/__main__.py", line 38, in
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/__init__.py", line 912, in get_default_cli
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/__init__.py", line 59, in __init__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 89, in __init__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/azlogging.py", line 45, in __init__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/log.py", line 98, in __init__
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/log.py", line 179, in _is_file_log_enabled
File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/config.py", line 145, in getboolean
ValueError: Not a boolean: ~/az-logs
```
1. To fix it, I had to manually edit the file in ~/.azure/config, to remove the incorrect setting
**To Reproduce**
1. Run: `az config set logging.enable_log_file=~/az-logs`
1. Run: `az config set logging.enable_log_file=true`
**Expected behavior**
The config value can be changed with the second command
**Environment summary**
MSI on Windows
```
C:\Users\antmarti>az version
{
"azure-cli": "2.27.1",
"azure-cli-core": "2.27.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"azure-devops": "0.20.0"
}
}
```
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.