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

execute_item_batch can't accept multiple items for upsert and delete operations #39523

Open
pamelafox opened this issue Feb 1, 2025 · 1 comment
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@pamelafox
Copy link
Member

  • Package Name: azure-cosmos
  • Package Version: 4.9.0
  • Operating System: Mac OS X
  • Python Version: Python 3.12

Describe the bug

I tried using code like this:

batch_operations = [
("upsert", tuple([session_item] + message_pair_items))
]
await container.execute_item_batch(batch_operations=batch_operations, partition_key=[entra_oid, session_id])

That results in an error in the SDK however ("operation" is undefined), arising from this code lacking "upsert"--

        elif len(args) == 2:
            if operation_type.lower() == "replace":
                operation = {"operationType": "Replace",
                             "id": args[0],
                             "resourceBody": args[1]}
            elif operation_type.lower() == "patch":
                operation = {"operationType": "Patch",
                             "id": args[0],
                             "resourceBody": {"operations": args[1]}}
                filter_predicate = kwargs.pop("filter_predicate", None)
                if filter_predicate is not None:
                    operation["resourceBody"]["condition"] = filter_predicate

Mark says that the .NET SDK has equivalent functionality for upsert and delete. And if for some reason they dont work, the error should be better.

@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 1, 2025
@xiangyan99 xiangyan99 added Cosmos Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Feb 3, 2025
Copy link

github-actions bot commented Feb 3, 2025

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AbhinavTrips @bambriz @Pilchie @pjohari-ms @simorenoh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos Service Attention Workflow: This issue is responsible by Azure service team.
Projects
Status: No status
Development

No branches or pull requests

2 participants