# Bug: Error trying to delete items with sub-query with multi-tenancy turned on

**URL:** <https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397>\
**Category:** Support\
**Tags:** bug\
**Created:** [July 19, 2023, 11:06pm UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397 "2023-07-19T23:06:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gabriel/32/250_2.png) [@gabriel](https://forum.weaviate.io/u/gabriel)\
**Post date:** [July 19, 2023, 11:06pm UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397/1 "2023-07-19T23:06:20Z")

</div>

Hi, I’m trying to port my code to Weaviate’s multi-tenant system and I am having trouble making a where query that takes a tenant id

When I try without the tenant in the path — ie

```auto
 # Delete all pages referencing the same book
        batch.delete_objects(
            class_name=PAGE_CLASS,
            where={
                "path": ["book", "Book", "id"],
                "operator": "Equal",
                "valueText": book_uuid,
            },
            tenant=metadata["library_id"],
        )

```

it gives

```auto
weaviate.exceptions.WeaviateBaseError: Delete in batch! Unexpected status code: 422, with response body: {'error': [{'message': 'batch delete objects: cannot find objects: find matching doc ids in shard "zbf4s7y11skueza82yvyulwg": nested query: nested clause at pos 1: nested request to fetch matching IDs: object search at index book: class Book has multi-tenancy enabled, but request was without tenant'}]}

```

It would seem that the tenant id isn’t passed to subqueries when going through the batch endpoint

---

<div class="post-metadata">

**Author:** ![antas-marcin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/antas-marcin/32/20_2.png) [@antas-marcin](https://forum.weaviate.io/u/antas-marcin)\
**Post date:** [July 20, 2023, 10:15am UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397/2 "2023-07-20T10:15:48Z")

</div>

Does the Book class (that you cross-reference) works also with Get queries? and does the Book class belong to the same tenant?

---

<div class="post-metadata">

**Author:** ![gabriel](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gabriel/32/250_2.png) [@gabriel](https://forum.weaviate.io/u/gabriel)\
**Post date:** [July 20, 2023, 2:37pm UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397/3 "2023-07-20T14:37:19Z")

</div>

@antas-marcin

> Does the Book class (that you cross-reference) works also with Get queries?

**No** (updated)

> does the Book class belong to the same tenant?

Yes

Here’s a notebook with a fully reproducible error: [multitenant-batch.ipynb · GitHub](https://gist.github.com/glesperance/92c9b9aa6e9387bcfdaab6ca6e2a518a)

---

<div class="post-metadata">

**Author:** ![gabriel](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gabriel/32/250_2.png) [@gabriel](https://forum.weaviate.io/u/gabriel)\
**Post date:** [July 20, 2023, 2:47pm UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397/4 "2023-07-20T14:47:13Z")

</div>

Actually @antas-marcin, just did a proper get + where query and it does not work. I updated the above post and [gist](https://gist.github.com/glesperance/92c9b9aa6e9387bcfdaab6ca6e2a518a).

---

<div class="post-metadata">

**Author:** ![gabriel](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gabriel/32/250_2.png) [@gabriel](https://forum.weaviate.io/u/gabriel)\
**Post date:** [July 31, 2023, 2:46pm UTC](https://forum.weaviate.io/t/bug-error-trying-to-delete-items-with-sub-query-with-multi-tenancy-turned-on/397/5 "2023-07-31T14:46:13Z")

</div>

The bug was fixed in the following patch release [Release v1.20.3 - Multi-Tenancy search using cross-reference and proper vector sync to target nodes during read repair Fixes · weaviate/weaviate · GitHub](https://github.com/weaviate/weaviate/releases/tag/v1.20.3)
