Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ def _get_drive_id(self) -> str:
ValueError: If there is an error in obtaining the drive ID.
"""
self._drive_id_endpoint = f"https://graph.microsoft.com/v1.0/sites/{self._site_id_with_host_name}/drives"

if hasattr(self, "_drive_id"):
return self._drive_id

if self.drive_id:
return self.drive_id

self._drive_id_endpoint = f"https://graph.microsoft.com/v1.0/sites/{self._site_id_with_host_name}/drives"

# Use generic pagination helper to get all drives
drives = self._get_all_items_with_pagination(self._drive_id_endpoint)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dev = [

[project]
name = "llama-index-readers-microsoft-sharepoint"
version = "0.8.0"
version = "0.8.1"
description = "llama-index readers microsoft_sharepoint integration"
authors = [{name = "Your Name", email = "you@example.com"}]
requires-python = ">=3.9,<4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,32 @@ def test_get_all_items_with_pagination_empty_result():
)

assert len(items) == 0


def test_drive_id_endpoint_set_when_drive_id_provided():
"""
Test that _drive_id_endpoint is set even when drive_id is provided directly.
Regression test for https://github.com/run-llama/llama_index/issues/18753
"""
reader = SharePointReader(
client_id="dummy_client_id",
client_secret="dummy_client_secret",
tenant_id="dummy_tenant_id",
drive_id="my_drive_id",
)
reader._site_id_with_host_name = "dummy_site_id"

# Bypass the autouse _get_drive_id mock by calling the unpatched method directly
# via the descriptor protocol on the original class
import importlib

mod = importlib.import_module("llama_index.readers.microsoft_sharepoint.base")
importlib.reload(mod)
orig_get_drive_id = mod.SharePointReader._get_drive_id
result = orig_get_drive_id(reader)

assert result == "my_drive_id"
assert reader._drive_id_endpoint == (
"https://graph.microsoft.com/v1.0/sites/dummy_site_id/drives"
)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.