`az storage entity insert` can create an entity with empty/missing RowKey, then `entity delete` cannot delete it
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
## Describe the bug
**Command Name**
`az storage entity insert`
... and relatedly ...
`az storage entity delete`
**Errors:**
`insert`: no errors, although there probably should've been;
`delete`:
```
The command failed with an unexpected error. Here is the traceback:
tuple index out of range
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/data/tables/_table_client.py", line 335, in delete_entity
IndexError: tuple index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 718, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/storage/__init__.py", line 411, in new_handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/storage/__init__.py", line 410, in new_handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/storage/operations/table.py", line 104, in delete_entity
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/data/tables/_table_client.py", line 344, in delete_entity
IndexError: tuple index out of range
```
## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Have an existing Storage Table
- Create an Entity with an empty RowKey
- `az storage entity insert [...] --entity PartitionKey="testpartition" RowKey=""`
```
{
"date": "2022-11-16T23:34:04+00:00",
"etag": "W/\"datetime'2022-11-16T23%3A34%3A05.2900934Z'\"",
"version": "2019-02-02"
}
```
- Observe that this entity was successfully created, with no RowKey value
- `az storage entity query [...]`
```
{
"PartitionKey": "testpartition",
"Timestamp": "2022-11-16T23:34:05.290093+00:00",
"etag": "W/\"datetime'2022-11-16T23%3A34%3A05.2900934Z'\""
}
```
- Attempt to delete, but this will fail
- `az storage entity delete [...] --partition-key "testpartition" --row-key ""`
```
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: tuple index out of range
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/data/tables/_table_client.py", line 335, in delete_entity
IndexError: tuple index out of range
[...]
```
## Expected Behavior
1. Probably, attempting to insert an entity with an empty RowKey should be disallowed or fail in some way.
2. Secondarily, the attempt to delete with an empty --row-key fails but doesn't clearly indicate why.
## Environment Summary
```
Windows-10-10.0.22621-SP0
Python 3.10.8
Installer: MSI
azure-cli 2.42.0
Extensions:
application-insights 0.1.16
scheduled-query 0.5.1
Dependencies:
msal 1.20.0
azure-mgmt-resource 21.1.0b1
```
## Additional Context
I didn't intend to insert an empty RowKey, that was due to a script error on my part, but here we are. :)
Contributor guide
Assessment
This issue has not been assessed yet.