Skip to content

Commit 29b7fb0

Browse files
leoredclaude
andcommitted
Fix UUID validation error when indexing new documents
Passing id=None explicitly to Document() overrode Pydantic's default_factory=uuid4, causing validation failures for new files. Now only includes id in kwargs when existing_id is not None. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 21179aa commit 29b7fb0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/kb_engine/pipelines/indexation/pipeline.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def _build_document(
170170

171171
metadata = {**frontmatter, "_parser": ft_config.parser}
172172

173-
return Document(
174-
id=existing_id,
173+
kwargs: dict = dict(
175174
title=frontmatter.get("title", title),
176175
content=content,
177176
source_path=str(scanner.repo_path / relative_path),
@@ -185,6 +184,9 @@ def _build_document(
185184
git_commit=commit,
186185
git_remote_url=remote_url,
187186
)
187+
if existing_id is not None:
188+
kwargs["id"] = existing_id
189+
return Document(**kwargs)
188190

189191
async def index_repository(self, repo_config: RepositoryConfig) -> list[Document]:
190192
"""Index all matching files from a Git repository."""

0 commit comments

Comments
 (0)