Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.89k stars 1.1k forks source link

clone_items gives 'useGlobalIds' parameter is invalid error, when copy_global_ids is True #2147

Open rkraujutis opened 2 days ago

rkraujutis commented 2 days ago

Describe the bug

Cloning item 2f1edd296d4346139a9978bdd35fa80a gives error:

raise _ItemCreateException(
arcgis._impl.common._clone._ItemCreateException: ("Failed to create Feature Service REDACTED: This operation is not supported.\n'useGlobalIds' parameter is invalid\nUnable to apply edits. Please check your parameters.\n(Error Code: 405)", <Item REDACTED>)

Source item is hosted feature table. There are no global identifier fields.

To Reproduce Steps to reproduce the behavior:

source_content:ContentManager = source_gis.content
source_item = source_content.get("2f1edd296d4346139a9978bdd35fa80a")

target_content:ContentManager = target_gis.content

try:
    for cloned_item in target_content.clone_items([
            source_item
        ],
        search_existing_items = False,
        copy_global_ids = True,
    ):
        logger.info(f'Cloned item: {cloned_item.itemid} {cloned_item}')
except:
    logger.warning(f"Failed clone {source_item.itemid}", exc_info=True)

error:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 2857, in _add_features
    edits = layers[layer_id].edit_features(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/features/layer.py", line 3318, in edit_features
    return self._con.post_multipart(path=edit_url, postdata=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1248, in post_multipart
    return self._handle_response(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 979, in _handle_response
    self._handle_json_error(data["error"], errorcode)
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1002, in _handle_json_error
    raise Exception(errormessage)
Exception: This operation is not supported.
'useGlobalIds' parameter is invalid
Unable to apply edits. Please check your parameters.
(Error Code: 405)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 4050, in clone
    self._add_features(
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 2875, in _add_features
    edits = layers[layer_id].edit_features(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/features/layer.py", line 3318, in edit_features
    return self._con.post_multipart(path=edit_url, postdata=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1248, in post_multipart
    return self._handle_response(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 979, in _handle_response
    self._handle_json_error(data["error"], errorcode)
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/_impl/_con/_connection.py", line 1002, in _handle_json_error
    raise Exception(errormessage)
Exception: This operation is not supported.
'useGlobalIds' parameter is invalid
Unable to apply edits. Please check your parameters.
(Error Code: 405)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/REDACTED.py", line 27, in test_2f1edd296d4346139a9978bdd35fa80a
    for cloned_item in target_content.clone_items([
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/gis/__init__.py", line 8757, in clone_items
    return deep_cloner.clone()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 1347, in clone
    results = executor.submit(self._clone, executor).result()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/opt/conda/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 1321, in _clone
    raise ex
  File "/opt/conda/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.12/site-packages/arcgis/_impl/common/_clone.py", line 4270, in clone
    raise _ItemCreateException(
arcgis._impl.common._clone._ItemCreateException: ("Failed to create Feature Service REDACTED: This operation is not supported.\n'useGlobalIds' parameter is invalid\nUnable to apply edits. Please check your parameters.\n(Error Code: 405)", <Item title:"REDACTED" type:Table Layer REDACTED>)

Expected behavior

Expected cloned item appear in target.

Platform (please complete the following information):

achapkowski commented 1 day ago

Your table doesn't have global ids:

image

rkraujutis commented 1 day ago

Yes. I know. I am cloning multiple items in bulk and other items has global identifiers. Bulk cloning fails because of this item.

Should I provide reproducable example, where cloning if being done with two items including additional one with globalid fields?