Describe the bug
An item with an empty name will cause a crash if this item is cloned.
To Reproduce
Steps to reproduce the behavior:
No particular piece of code, just a simple call to 'clone_items' will trigger the crash when an item has an empty name.
agol.content.clone_items(items=[itemWithEmptyName])
Here is my workflow that lead me to this problem : I share some items of my portal through a collaboration towards ArcGIS Online. Then, once in ArcGIS Online, I try to clone the recently appeared items using the arcgis Python API. However, a crash occurs during the 'clone_items' function call of the arcgis Python API. The empty 'name' property of the item is the cause of the crash. In my portal source item, the item.name is None (not on all of my items, but on some of them. I don't know if it is normal or if it is legacy after upgrading my arcgis enterprise). Once such item is created in ArcGIS Online through collaboration, the name property is not None anymore, but it became an empty string ''. And this empty string is the cause of the crash during the clone_items step of my workflow.
error:
in arcgis Python 2.3.0
Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis_impl\common_clone.py", line 2945, in clone
name = self._get_unique_name(self.target, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis_impl\common_clone.py", line 2850, in _get_unique_name
if name[0].isdigit():
~~~~^^^
IndexError: string index out of range
Expected behavior
In my opinion, 2 or maybe 3 problems occur during this workflow :
name = original_item["name"] if name is None: name = os.path.basename(os.path.dirname(original_item["url"])) name = re.sub("\W+", "_", name) name = self._get_unique_name(self.target, name)
The test 'if name is None' might not be robust enough and should treat the empty string too (or do something else accordingly) before the 'self._get_unique_name' call in which the 'name[0]' crashes.
Platform:
Additional context
Original problem opened there, a colleague of yours pointed me here.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4