A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Esri/arcgis-python-api/issues/1872 below:

Empty 'name' property of an arcgis item object causes crash when trying to clone · Issue #1872 · Esri/arcgis-python-api · GitHub

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 :

  1. 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.
  2. 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.
  3. 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:
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