Skip to content

fix(connectors): resolve SharePoint folder paths against the right document library - #6026

Merged
waleedlatif1 merged 1 commit into
stagingfrom
worktree-sharepoint-folder-path-fix
Jul 28, 2026
Merged

fix(connectors): resolve SharePoint folder paths against the right document library#6026
waleedlatif1 merged 1 commit into
stagingfrom
worktree-sharepoint-folder-path-fix

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Folder-scoped SharePoint connectors failed with Folder not found for folders that exist and are readable with the same credential — whole-library sync was the only working option
  • Resolve the target drive explicitly and thread it through listing, download and hydration, which all previously hardcoded the site's default library
  • Resolve folder paths in layers: byte-exact addressing first (unchanged from today), then a leading document-library name, then a normalized children walk that recovers names carrying non-breaking or invisible whitespace
  • Accept a folder URL pasted from the browser address bar
  • Report the site, library, attempted path and existing folder names on failure instead of a bare Folder not found
  • Document the expected folder path format in the connector schema — the old placeholder (Documents/Reports) taught a form that can never resolve, since root: is already the library root

Notes on compatibility

  • Exact path addressing runs first and is byte-identical to the current request, so any configuration that resolves today resolves to the same item. The new layers only run on a path that already 404'd — covered by a test asserting a real folder named Documents still wins over the library-name interpretation
  • The default drive is resolved via GET /sites/{siteId}/drive (the documented default library), not drives[0], whose ordering is not guaranteed — so item.id is unchanged and no documents are re-indexed
  • No scope change: Sites.Read.All covers every endpoint used. Tokenized /:f:/ sharing links are deliberately not supported — resolving them requires /shares, which needs write scopes this connector should not hold
  • Pagination cursors are per-run and never persisted (sync-engine.ts), so the cursor state change has no upgrade surface

Type of Change

  • Bug fix

Testing

22 unit tests against a mocked Graph covering exact paths, leading/trailing slashes, nested folders, Documents/Shared Documents prefixes, non-default libraries, non-breaking-space and case recovery, ambiguity rejection, address-bar URLs, sharing-link rejection, and the diagnostic error contents. Full connector suite (468 tests) passes. Not verified against a live tenant.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…cument library

Folder-scoped SharePoint connectors failed with "Folder not found" for
folders that exist and are readable with the same credential, leaving
whole-library sync as the only option.

- resolve the target drive explicitly and thread it through listing,
  download and hydration, which previously hardcoded the site default
- resolve folder paths in layers: byte-exact addressing first (unchanged),
  then a leading document-library name, then a normalized children walk
  that recovers names carrying non-breaking or invisible whitespace
- accept a folder URL from the browser address bar
- report the site, library, attempted path and existing folder names on
  failure instead of a bare "Folder not found"
- document the expected folder path format in the connector schema
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 28, 2026 11:11pm

Request Review

@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes SharePoint connector sync and path resolution behavior (more Graph calls on fallback paths), though exact-path configs stay byte-identical; mis-resolution could sync the wrong library until caught by validation or errors.

Overview
Fixes folder-scoped SharePoint syncs that failed with bare Folder not found even when the folder exists, by resolving the target document library (drive) and threading driveId through listing, download, hydration, and validation instead of always using the site default library.

Folder path resolution is now layered: byte-exact path on the default library first (same as before), then treating a leading segment as another library name (e.g. Policies/HR or stripping Shared Documents/), then a normalized children walk for NBSP/case/invisible characters. Users can paste a browser folder URL (including ?id= forms); tokenized sharing links are rejected with guidance. Failures report site, library, path, and sibling folder names. Connector meta updates the placeholder/description so paths are library-relative.

Adds ~22 unit tests with a mocked Microsoft Graph for these resolution paths.

Reviewed by Cursor Bugbot for commit 8e304fa. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes SharePoint folder-scoped connector resolution by targeting the correct document library instead of always using the site default drive.

  • Resolves the default drive via GET /sites/{siteId}/drive and threads driveId through list, download, and hydrate paths
  • Layers folder-path resolution: exact path, leading library-name strip/switch, then normalized children walk (NBSP/case recovery)
  • Accepts browser address-bar folder URLs; rejects tokenized sharing links with guidance
  • Improves not-found diagnostics and meta placeholder/description; adds focused unit coverage

Confidence Score: 5/5

Safe to merge; no blocking defects identified in the drive-aware SharePoint folder resolution changes.

Exact path addressing remains first and byte-compatible; drive identity is resolved via the documented default library endpoint and reused for listing and hydration; URL handling and failure messaging are covered by unit tests without a reachable incorrect-resolution path in the diff.

Important Files Changed

Filename Overview
apps/sim/connectors/sharepoint/sharepoint.ts Drive-aware path resolution and Graph calls; layered fallbacks preserve prior exact-path behavior and cache driveId on syncContext.
apps/sim/connectors/sharepoint/sharepoint.test.ts Broad mocked-Graph coverage for exact paths, library prefixes, NBSP/case recovery, URLs, and errors.
apps/sim/connectors/sharepoint/meta.ts Corrects folder-path placeholder/description so users omit the library root name.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[folderPath / URL] --> B[Resolve default drive]
  B --> C{Exact path on default drive?}
  C -->|yes| D[driveId + folderId]
  C -->|404| E{Leading segment matches a library?}
  E -->|yes| F[Exact / walk remainder on that library]
  F -->|hit| D
  F -->|miss| G[Normalized children walk on default]
  E -->|no| G
  G -->|hit| D
  G -->|miss| H[Diagnostic Folder not found]
  D --> I[listDocuments / getDocument via /drives/driveId]
Loading

Reviews (1): Last reviewed commit: "fix(connectors): resolve SharePoint fold..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit c77300f into staging Jul 28, 2026
19 of 20 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-sharepoint-folder-path-fix branch July 28, 2026 23:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8e304fa. Configure here.

Comment thread apps/sim/connectors/sharepoint/sharepoint.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant