From 8340c69f8527525ebde2d4a9b0c5503cd87be0d8 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:20:19 +0100 Subject: [PATCH] fix: fixes local file case --- .../v1/datasets/routers/get_datasets_router.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cognee/api/v1/datasets/routers/get_datasets_router.py b/cognee/api/v1/datasets/routers/get_datasets_router.py index ca738dfbe..8e4eb3b4e 100644 --- a/cognee/api/v1/datasets/routers/get_datasets_router.py +++ b/cognee/api/v1/datasets/routers/get_datasets_router.py @@ -8,6 +8,8 @@ from fastapi import APIRouter from fastapi.encoders import jsonable_encoder from fastapi import HTTPException, Query, Depends from fastapi.responses import JSONResponse, FileResponse +from urllib.parse import urlparse +from pathlib import Path from cognee.api.DTO import InDTO, OutDTO from cognee.infrastructure.databases.relational import get_relational_engine @@ -475,6 +477,18 @@ def get_datasets_router() -> APIRouter: message=f"Data ({data_id}) not found in dataset ({dataset_id})." ) - return data.raw_data_location + raw_location = data.raw_data_location + + if raw_location.startswith("file:"): + raw_location = urlparse(raw_location).path + + path = Path(raw_location) + + if not path.is_file(): + raise DataNotFoundError( + message=f"Raw file not found on disk for data ({data_id})." + ) + + return FileResponse(path=path) return router