zylon-ai/private-gpt · error · ValueError
collection is required in context
Error message
collection is required in context
What it means
ValueError from TabularDataToolBuilder._validate_context: context_filter was given but collection is empty. The collection plus each artifact form a VectorArtifactIndex used to locate the tabular data, so an empty collection cannot resolve any index.
Source
Thrown at private_gpt/components/tools/builders/tabular_data_builder.py:128
sandbox_component: SandboxComponent,
) -> None:
self.settings = settings
self.llm_component = llm_component
self.vector_store_component = vector_store_component
self.node_store_component = node_store_component
self.embedding_component = embedding_component
self.ingest_component = ingest_component
self.parse_component = parse_component
self.sandbox_component = sandbox_component
async def _validate_context(
self, context_filter: ContextFilter | None
) -> ContextFilter:
if not context_filter:
raise ValueError("context_filter is required")
if not context_filter.collection:
raise ValueError("collection is required in context")
# If artifacts are provided, verify the related required indexes are ready
# or throw an error
artifacts = (
list(set(context_filter.artifacts)) if context_filter.artifacts else None
)
if artifacts:
tasks: list[Coroutine[Any, Any, None]] = []
for artifact in artifacts:
vector_artifact_index = VectorArtifactIndex(
collection=context_filter.collection,
artifact=artifact,
vector_store_component=self.vector_store_component,
node_store_component=self.node_store_component,
embedding_component=self.embedding_component,
ingest_component=self.ingest_component,
parse_component=self.parse_component,
)View on GitHub (pinned to 4a030776a3)
Solutions
- Set context_filter.collection to the collection where the tabular artifacts were ingested.
- Cross-check that artifacts listed in the filter exist under that collection.
Example fix
# before context_filter = ContextFilter(artifacts=[artifact_id]) # after context_filter = ContextFilter(collection="default", artifacts=[artifact_id])
Defensive patterns
Strategy: validation
Validate before calling
if not context_filter.collection:
raise ValueError("context_filter.collection required to locate tabular indexes") Type guard
def has_collection(cf) -> bool:
return cf is not None and bool(getattr(cf, "collection", None)) Prevention
- Always set collection alongside artifacts — artifacts alone are not enough.
- Confirm tabular artifacts were ingested into that collection before analysis.
When it happens
Trigger: Calling the tabular data tool with a ContextFilter whose collection is None or ''; the check runs before the artifact verification loop.
Common situations: Caller constructs ContextFilter with only artifacts set; collection field lost during serialization; using a custom collection name but sending the empty default.
Related errors
- collection is required in context
- collection is required in context
- context_filter is required
- Invalid system specification (dict): {system}
- Invalid system item in list (dict): {item}
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/976ee64f61e8b2b4.
Report an issue: GitHub.