zylon-ai/private-gpt · error · HTTPException

File '{file_id}' not found or is a sandbox output (cannot be

Error message

File '{file_id}' not found or is a sandbox output (cannot be deleted).

What it means

Error "File '{file_id}' not found or is a sandbox output (cannot be deleted)." thrown in zylon-ai/private-gpt.

Source

Thrown at private_gpt/server/files/file_service.py:212

        canonical = _decode_file_id(file_id)
        storage_path = _canonical_to_storage_path(canonical)
        self._validate_file_id(storage_path)
        _folder, filename = storage_path.split("/", 1)
        prefix = self._prefix_for_path(storage_path, scope_id)
        file_info = await storage.stat_file(prefix, filename)
        if file_info is None:
            raise HTTPException(status_code=404, detail=f"File '{file_id}' not found.")
        content = await storage.read_file(prefix, filename)
        display_name = canonical.split("/")[-1]
        return content, file_info.mime_type, display_name

    async def delete_file(self, scope_id: str, file_id: str) -> DeletedFile:
        storage = self._require_storage()
        canonical = _decode_file_id(file_id)
        storage_path = _canonical_to_storage_path(canonical)
        self._validate_file_id(storage_path)
        if not storage_path.startswith("uploads/"):
            raise HTTPException(
                status_code=404,
                detail=f"File '{file_id}' not found or is a sandbox output (cannot be deleted).",
            )
        _folder, filename = storage_path.split("/", 1)
        deleted = await storage.delete_file(self._uploads_prefix(scope_id), filename)
        if not deleted:
            raise HTTPException(
                status_code=404,
                detail=f"File '{file_id}' not found or is a sandbox output (cannot be deleted).",
            )
        return DeletedFile(id=file_id)

    @staticmethod
    def _validate_file_id(file_id: str) -> None:
        if ".." in file_id.split("/"):
            raise HTTPException(status_code=400, detail="Invalid file ID.")

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Verify the file_id exists by listing files before attempting deletion.
  2. Check that the file is not a sandbox output; sandbox output files cannot be deleted.
  3. Ensure you are not deleting a file that was generated as a sandbox output artifact.
  4. Confirm the file belongs to the current session and has not already been deleted.

When it happens

Trigger: Raised when a delete request references a file_id that does not exist or points to a file produced as sandbox output, which is protected from deletion.

Common situations: Attempting to delete a file via the files API with an unknown id, or trying to delete a generated sandbox output file instead of an uploaded one.


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