You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 :
I don't know if the 'name' property of an item should be None or empty in the first place. I don't know how this property is forged and what are its purprose and usages (equals to 'title' most of the case), so maybe this isn't a real problem. But just for you to know : it can happen in production.
the collaboration between my portal and ArcGIS Online doesn't recreate the item identically, as a None item.name becomes an empty string. I would expect an None property to remain None after collaboration. Maybe this problem should be forwarded to another dev team that works on collaboration.
And empty name causes the crash in the python clone_items call. It is due to the following piece of code line 2941 of the _clone.py script of the arcgis Python module:
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:
OS: Windows (irrelevant to the problem)
Browser : Chrome (irrelevant to the problem)
Python API Version : crash reproduced in 1.8.5 and in 2.3.0
ArcGIS Enterprise : 10.91
Additional context
Original problem opened there, a colleague of yours pointed me here.
The text was updated successfully, but these errors were encountered:
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.
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
Expected behavior
In my opinion, 2 or maybe 3 problems occur during this workflow :
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.
The text was updated successfully, but these errors were encountered: