opened 11:55AM - 02 Jul 24 UTC
bug
### How to reproduce this bug?
As per the weaviate documentation one should be …able to cross reference from a multi tenant to a non multi tenant.
Run the below script
```
import random
import string
from weaviate.classes.config import Property, DataType, ReferenceProperty
import weaviate
import weaviate.classes.config as wvc
from weaviate.classes.tenants import Tenant
from weaviate.classes.query import QueryReference
client = weaviate.connect_to_local()
# Create collection
if (client.collections.exists("JeopardyCategory")):
# delete collection "Article" - THIS WILL DELETE THE COLLECTION AND ALL ITS DATA
client.collections.delete("JeopardyCategory") # Replace with your collection name
# Create collection
if (client.collections.exists("JeopardyQuestion")):
# delete collection "Article" - THIS WILL DELETE THE COLLECTION AND ALL ITS DATA
client.collections.delete("JeopardyQuestion") # Replace with your collection name
category = client.collections.create(
name="JeopardyCategory",
description="A Jeopardy! category",
properties=[
Property(name="title", data_type=DataType.TEXT)
],
replication_config=wvc.Configure.replication(factor=1),
)
jeopardy_question= client.collections.create(
name="JeopardyQuestion",
description="A Jeopardy! question",
properties=[
Property(name="question", data_type=DataType.TEXT),
Property(name="answer", data_type=DataType.TEXT),
],
references=[
ReferenceProperty(
name="hasCategory",
target_collection="JeopardyCategory"
)
],
replication_config=wvc.Configure.replication(factor=1),
multi_tenancy_config=wvc.Configure.multi_tenancy(enabled=True, auto_tenant_creation=True, auto_tenant_activation=True)
)
# Create tenant on JeopardyQuestion
jeopardy_question.tenants.create(
tenants=[
Tenant(name="tenantA"),
Tenant(name="tenantB"),
]
)
# Insert objects to the collection
def get_random_string(length):
# choose from all lowercase letter
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
# print("Random string of length", length, "is:", result_str)
# Add category to JeopardyCategory
jeopardy = client.collections.get("JeopardyCategory")
category_uuid = jeopardy.data.insert({
"title": get_random_string(10)
})
questions= jeopardy_question.with_tenant(tenant="tenantA")
questions.data.insert({
"question": "question" + get_random_string(10),
"answer" : "answer"+ get_random_string(10)
},
references={"hasCategory": category_uuid}, # e.g. {"hasCategory": "583876f3-e293-5b5b-9839-03f455f14575"}
)
response = questions.query.fetch_objects(return_references=QueryReference(link_on="hasCategory", return_properties=["question", "answer"]))
for o in response.objects:
print(o.properties)
client.close()
```
### What is the expected behavior?
No error should be displayed and user should be able to query the reference property in a multitenant collection.
### What is the actual behavior?
```
weaviate.exceptions.WeaviateQueryError: Query call with protocol GRPC search failed with message <AioRpcError of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index "jeopardycategory": class JeopardyCategory has multi-tenancy disabled, but request was with tenant"
debug_error_string = "UNKNOWN:Error received from peer {created_time:"2024-07-01T19:38:14.318273+01:00", grpc_status:2, grpc_message:"explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index \"jeopardycategory\": class JeopardyCategory has multi-tenancy disabled, but request was with tenant"}"
>.
```
### Supporting information
https://weaviate.io/developers/weaviate/manage-data/multi-tenancy#cross-references
### Server Version
1.25.6
### Code of Conduct
- [X] I have read and agree to the Weaviate's [Contributor Guide](https://weaviate.io/developers/contributor-guide) and [Code of Conduct](https://weaviate.io/service/code-of-conduct)