{"record":{"id":"976ee64f61e8b2b4","repo":"zylon-ai/private-gpt","slug":"collection-is-required-in-context-976ee6","errorCode":null,"errorMessage":"collection is required in context","messagePattern":"collection is required in context","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tools/builders/tabular_data_builder.py","lineNumber":128,"sourceCode":"        sandbox_component: SandboxComponent,\n    ) -> None:\n        self.settings = settings\n        self.llm_component = llm_component\n        self.vector_store_component = vector_store_component\n        self.node_store_component = node_store_component\n        self.embedding_component = embedding_component\n        self.ingest_component = ingest_component\n        self.parse_component = parse_component\n        self.sandbox_component = sandbox_component\n\n    async def _validate_context(\n        self, context_filter: ContextFilter | None\n    ) -> ContextFilter:\n        if not context_filter:\n            raise ValueError(\"context_filter is required\")\n\n        if not context_filter.collection:\n            raise ValueError(\"collection is required in context\")\n\n        # If artifacts are provided, verify the related required indexes are ready\n        # or throw an error\n        artifacts = (\n            list(set(context_filter.artifacts)) if context_filter.artifacts else None\n        )\n        if artifacts:\n            tasks: list[Coroutine[Any, Any, None]] = []\n            for artifact in artifacts:\n                vector_artifact_index = VectorArtifactIndex(\n                    collection=context_filter.collection,\n                    artifact=artifact,\n                    vector_store_component=self.vector_store_component,\n                    node_store_component=self.node_store_component,\n                    embedding_component=self.embedding_component,\n                    ingest_component=self.ingest_component,\n                    parse_component=self.parse_component,\n                )","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tools/builders/tabular_data_builder.py#L110-L146","documentation":"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.","triggerScenarios":"Calling the tabular data tool with a ContextFilter whose collection is None or ''; the check runs before the artifact verification loop.","commonSituations":"Caller constructs ContextFilter with only artifacts set; collection field lost during serialization; using a custom collection name but sending the empty default.","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."],"exampleFix":"# before\ncontext_filter = ContextFilter(artifacts=[artifact_id])\n\n# after\ncontext_filter = ContextFilter(collection=\"default\", artifacts=[artifact_id])","handlingStrategy":"validation","validationCode":"if not context_filter.collection:\n    raise ValueError(\"context_filter.collection required to locate tabular indexes\")","typeGuard":"def has_collection(cf) -> bool:\n    return cf is not None and bool(getattr(cf, \"collection\", None))","tryCatchPattern":null,"preventionTips":["Always set collection alongside artifacts — artifacts alone are not enough.","Confirm tabular artifacts were ingested into that collection before analysis."],"tags":["validation","tabular","collection"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}