Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rkraujutis opened this issue Oct 29, 2024 · 3 comments

Comments

@rkraujutis
Copy link

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):

  • OS: Linux
  • Browser: -
  • Python API Version: 2.4.0
@rkraujutis rkraujutis added the bug label Oct 29, 2024
@achapkowski
Copy link
Contributor

Your table doesn't have global ids:

image

@rkraujutis
Copy link
Author

rkraujutis commented Oct 30, 2024

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?

@jake-eagle
Copy link

@achapkowski I agree with @rkraujutis, I think this is an issue that needs to be resolved as clone_items() is documented to be able to migrate items in bulk.

Imagine you want to clone a Web Map with two layers, one has GlobalIDs (which you want to retain), the other does not have a GlobalID field. clone_items() on the Web Map fails if copy_global_ids = True as the second layer does not contain GlobalIDs. You would have to first clone the layers (specifying copy_global_ids=True for the first layer only) before cloning the Web Map.

I think the preferable approach here is for the ArcGIS API for Python to handle this - retain GlobalIDs if they exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants