WeaviateStartUpError
weaviate.exceptions.WeaviateStartUpError
Stack trace
weaviate.exceptions.WeaviateStartUpError: Class 'MyVectorClass' not found in Weaviate schema
File "/app/query_weaviate.py", line 42, in query_vector
response = client.query.get('MyVectorClass', ['text']).with_near_vector(near_vector).do()
File "/usr/local/lib/python3.9/site-packages/weaviate/client.py", line 123, in get
raise WeaviateStartUpError(f"Class '{class_name}' not found in schema") Why it happens
This error occurs when the Weaviate client attempts to query a class that is not registered in the Weaviate instance's schema. The class name must exactly match a class defined in the schema, including case sensitivity. If the class was never created or was deleted, the query will fail with this error.
Detection
Check the Weaviate schema before querying by calling client.schema.get() and verify the class exists. Log the schema classes at startup to catch missing or misspelled class names early.
Causes & fixes
The class name used in the query does not exist in the Weaviate schema.
Verify the class name by fetching the schema with client.schema.get() and use the exact class name in your query.
The class was never created or was deleted from the Weaviate instance.
Create the class in the Weaviate schema before querying using client.schema.create_class() or via the Weaviate dashboard.
Typo or case mismatch in the class name string used in the query.
Ensure the class name string matches exactly the schema class name, including capitalization.
Querying before the Weaviate instance is fully initialized or schema is loaded.
Add a schema existence check or delay queries until the schema is confirmed loaded.
Code: broken vs fixed
import os
import weaviate
client = weaviate.Client(url=os.environ['WEAVIATE_URL'],
auth_client_secret=weaviate.AuthApiKey(api_key=os.environ['WEAVIATE_API_KEY']))
near_vector = {"vector": [0.1, 0.2, 0.3], "certainty": 0.7}
# This line triggers the error because 'MyVectorClass' does not exist
response = client.query.get('MyVectorClass', ['text']).with_near_vector(near_vector).do()
print(response) import os
import weaviate
client = weaviate.Client(url=os.environ['WEAVIATE_URL'],
auth_client_secret=weaviate.AuthApiKey(api_key=os.environ['WEAVIATE_API_KEY']))
# Verify schema classes before querying
schema = client.schema.get()
class_names = [cls['class'] for cls in schema.get('classes', [])]
assert 'MyVectorClass' in class_names, "Class 'MyVectorClass' not found in schema"
near_vector = {"vector": [0.1, 0.2, 0.3], "certainty": 0.7}
response = client.query.get('MyVectorClass', ['text']).with_near_vector(near_vector).do() # Fixed: class verified
print(response) Workaround
Wrap the query call in try/except WeaviateStartUpError, and if caught, fetch the schema and log available classes to diagnose missing class issues dynamically.
Prevention
Implement schema validation at app startup and before queries, and automate schema creation or migration scripts to ensure all required classes exist in Weaviate.