zylon-ai/private-gpt · error · ValueError

collection is required in context

Error message

collection is required in context

What it means

ValueError from SummaryToolBuilder._validate_context: a context_filter was provided but collection is empty. The collection selects the vector store / node store indexes used to build the retriever for summarization; without it the retriever cannot be constructed.

Source

Thrown at private_gpt/components/tools/builders/summary_builder.py:82

        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.content_service = content_service
        self.prompt_builder_service = prompt_builder_service

    def _create_text_retriever(self, texts: list[str]) -> InMemoryRetriever:
        """Create an in-memory retriever for text summarization."""
        return InMemoryRetriever.from_texts(texts=texts)

    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")

        assert self.vector_store_component, "Vector store component is required"
        assert self.node_store_component, "Node store component is required"
        assert self.embedding_component, "Embedding component is required"
        assert self.ingest_component, "Ingest component is required"
        assert self.parse_component, "Parse component is required"
        assert self.content_service, "Content service is required"

        # If artifacts are provided, verify the related required indexes are ready
        # or throw an error
        if context_filter.artifacts:
            for artifact in context_filter.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,

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Set context_filter.collection to the collection holding the documents to summarize.
  2. Verify the collection was populated during ingestion; an empty-but-valid collection will summarize nothing.

Example fix

# before
context_filter = ContextFilter()

# after
context_filter = ContextFilter(collection="default")
Defensive patterns

Strategy: validation

Validate before calling

assert context_filter is not None and context_filter.collection, "collection required"
workflow = builder.build(context_filter=context_filter)

Type guard

def is_summarizable_context(cf) -> bool:
    return cf is not None and bool(getattr(cf, "collection", None))

Prevention

When it happens

Trigger: Calling the summary tool with context_filter whose collection is None/empty; the check runs before the component asserts and artifact index verification.

Common situations: Default-constructed ContextFilter (collection defaults to empty) passed through; copy-paste from a filter schema that uses a different field name (e.g. index_name) for the collection.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/6ab2b199b73072b4. Report an issue: GitHub.