I am currently writing a python script to manipulate items, either from ArcGIS Online or from an ArcGIS Portal, and I am facing a problem due to the 'name' property of the arcgis.gis.Item object.
At first, I didn't know about this property (I am more familiar with 'title' or 'itemid'), so I don't know what value this property is supposed to contain, neither how to fill it. It is often identical to the 'title' property, but some of my items have the value None (I don't know if it is a legacy herited from previous versions of my portal).
I tried to update this property with the following piece of code, but it had no effect (eventhough the result was True) :
result = item.update(item_properties={'name': item.title})
It would be harmless most of the time, but the real problem I am facing occurs when I work with a collaboration between my ArcGIS Portal and ArcGIS Online. My items are shared as copies and, once copied into ArcGIS Online, I noticed that the items with a None 'name' suddendly have 'name' equals to the empty string ''. Later in my workflow I try to clone some of those items, but the function gis.content.clone_items crashes withe the following message :
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 2811, 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 2719, in _get_unique_name
if name[0].isdigit():
IndexError: string index out of range
Indeed, the clone function checks if the 'name' property of the item to clone is None, but doesn't check the empty string case, hence the crash :

To sum up : I am unable to clone items that have transited through a collaboration, because of their 'name' property that has been transformed from None to ''.
So, my questions are :
- How/when is the 'name' property of an item initialized or updated, and is it possible to do it either manually in the brower or with python ? Is it normal to have a None value for this property ?
- There is obviously an issue with the Collaboration which doesn't transfer the properties identically from my portal to ArcGIS Online (None becomes ''), so is there a way to fix this behavior ?
- The python function clone_items works when the 'name' is None, but crashes when the 'name' propery is equals to '', so it is not robust enough for my workflow. Is there another way to clone such items ?
PS : I work with an ArcGIS Enterprise 10.9.1
Thank you for your help.