Handbook
201-06 — SharePoint library reads
A read-only SharePoint library workflow: normalized site URL, health probe, and a governed list task (sharepoint_list_library_files_*) chosen for your tenant constraints.
Updated
What you will build
A read-only SharePoint library workflow: normalized site URL, health probe, and a governed list task (sharepoint_list_library_files_*) chosen for your tenant constraints.
Goal
Run read-only SharePoint library workflows with source/action task names and pick the right list strategy.
Prerequisites
- 201-01 — contracts mindset
pip install -e ".[dev]"in forge-lcdl- For live list tasks: Edge + CDP (see forge-knowledge-assistant
start-edge-for-assistant.sh)
Steps
1. Normalize URLs (offline)
PYTHONPATH=src python3 -c "
from forge_lcdl.env import LlmEnvProfile
from forge_lcdl.tasks.sharepoint_read_v1 import run_sharepoint_normalize_library_url_v1
from forge_lcdl.result import Ok
p = LlmEnvProfile(kind='certificator', base_url='http://127.0.0.1:9/v1', api_key='', model='m', timeout_sec=30, ngrok_bypass=False, prefer_json_object_mode=True)
out = run_sharepoint_normalize_library_url_v1({'site_url': 'https://contoso.sharepoint.com/sites/Engineering'}, profile=p)
assert isinstance(out, Ok)
print(out.value)
"
2. Register a Playwright session
Use PlaywrightPageSession.from_page(page) and InMemoryPlaywrightSessionProvider.register(ref, session). Do not call attach(string) after from_page — it overwrites the page handle.
3. Probe before expensive lists
Task: sharepoint_probe_library_health — input session_ref + url or query.site_url.
4. Choose a list task
| Need | task_id |
|---|---|
| Full folder (preferred) | sharepoint_list_library_files_rest |
| REST blocked | sharepoint_list_library_files_scroll |
| Visible rows only | sharepoint_list_library_files_viewport |
| Column metadata | sharepoint_list_library_files_columns |
See SharePoint library read strategies for timing and stability.
5. Run offline tests
PYTHONPATH=src python3 -m pytest tests/playwright/test_playwright_sharepoint_tasks.py -q
Expected output
sharepoint_normalize_library_url_v1prints a canonical library URL and site root.- Offline SharePoint task tests pass (
pytestcommand above). - Live runs return
Okwire JSON withitemsand optionalwarnings(never silent empty success on blocked REST).
Common failures
| Symptom | Likely cause |
|---|---|
not_attached |
Session ref missing or attach() overwrote a from_page session |
Empty items on scroll |
Library not scrolled to end; prefer REST or increase scroll rounds |
| REST list errors | Tenant blocks _api/web/lists; fall back to sharepoint_list_library_files_scroll |
Verify
Re-run the offline pytest module and confirm the normalize-url snippet returns Ok before attempting live CDP lists.
Changelog
| Version | Change |
|---|---|
| v1 | Initial lesson for canonical sharepoint_* tasks |