Conversation
Extract SharePoint permission data from Graph API and normalize to the standard read/update/delete schema used by other connectors. Permissions are fetched via Graph JSON batching (up to 20 per round-trip) with per-item fallback on batch failure. PLU-331
|
Validated end-to-end locally against a live SharePoint tenant using "permissions_data": [
{"read": {"users": ["e3638d7e-708b-..."], "groups": ["e3638d7e-708b-..."]}},
{"update": {"users": ["e3638d7e-708b-..."], "groups": ["e3638d7e-708b-..."]}},
{"delete": {"users": ["e3638d7e-708b-..."], "groups": ["e3638d7e-708b-..."]}}
]Both fixes confirmed working:
|
| """ | ||
| perms = drive_item.permissions | ||
| drive_item.properties["permissions"] = perms | ||
| return perms |
There was a problem hiding this comment.
Pinned permissions may not survive batch execution
High Severity
_pin_permissions stores the PermissionCollection in drive_item.properties["permissions"], but the office365 library's execute_batch() may reset object properties during response processing (e.g. via clear_state()). If the pin is cleared, drive_item.permissions in drive_item_to_file_data_sync returns a fresh empty collection, causing list(drive_item.permissions) to be empty and permissions_data to silently remain None for every file. This matches the reviewer's observation that the fetched collection is "ephemeral and discarded after execute_batch."
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 786d018. Configure here.
There was a problem hiding this comment.
False positive. This has been addressed. Both validation and the regenerated fixtures would show null if execute_batch was still clearing the pin.
Regenerate expected results against live SharePoint to include the permissions_data field now populated by the ACL passthrough.
993be6b to
7cb9a08
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7cb9a08. Configure here.
| """Normalize Graph API permissions to the standard read/update/delete format.""" | ||
| if not permissions: | ||
| logger.debug("no permissions found") | ||
| return [{}] |
There was a problem hiding this comment.
Inconsistent return schema for empty permissions list
Low Severity
extract_permissions returns [{}] when the input list is empty, which doesn't conform to the standard [{"read": ...}, {"update": ...}, {"delete": ...}] schema documented in the docstring and used by Google Drive and Confluence connectors. Any downstream consumer iterating over the result and accessing e.g. list(entry.keys())[0] would get an IndexError on the empty dict. While the current call site in drive_item_to_file_data_sync guards with if perms, the method is public and the inconsistency could cause issues if reused elsewhere.
Reviewed by Cursor Bugbot for commit 7cb9a08. Configure here.
There was a problem hiding this comment.
Won't fix.
I don't like the inconsistency here either, but this is following a pre-existing convention from the other connectors and is a non-issue in practice since drive_item_to_file_data_sync is guarded by if perms:.
I chose to stay consistent with existing behavior here, and if we want to revisit that (breaking change on multiple connectors) we should make that change separately and version accordingly.


Summary
[{read: {users, groups}}, {update: ...}, {delete: ...}]schema used by Google Drive and Confluence connectors./$batch, up to 20 per round-trip) with automatic per-item fallback on batch failure.permission.propertiesJSON to avoid cross-field data bleed in the office365 typed accessors.Details
MICROSOFT_ROLE_MAPPINGcovering Graph standard roles and SharePoint-specificsp.*roles._extract_identity_ids_from_raw()to pull Azure AD user/group IDs fromgrantedToV2(preferred) withgrantedTofallback. SharePointsiteGroupnumeric IDs are excluded (not resolvable via Graph).extract_permissions()to normalize raw Graph permissions into the canonical schema._fetch_permissions_batched()with queue-drain guard on batch failure andClientRequestExceptionhandling per item in fallback.run_asyncto window-and-yield in chunks of 20 instead of materializing the full file list.Limitations
$expand=permissionson DriveItem collections, so permissions are fetched separately per batch.Closes PLU-331
Note
Medium Risk
Touches SharePoint indexing flow and adds external Graph batching/fallback logic; failures could impact metadata completeness or indexing performance, though behavior is largely additive and covered by extensive tests.
Overview
Adds SharePoint ACL pass-through by fetching Graph
DriveItempermissions and normalizing them into the canonical[{read},{update},{delete}]permissions_dataschema.Implements Graph
/$batchpermission hydration (20 items per batch) with a per-item fallback on batch failure, plus raw-JSON identity extraction and aMICROSOFT_ROLE_MAPPINGto translate Microsoft/SharePoint roles into operations. Updatesrun_asyncto process files in permission-hydrated chunks, and extends unit + integration fixtures to validate deterministic, merged ACL output.Bumps package version to
1.5.0and documents the enhancement inCHANGELOG.md.Reviewed by Cursor Bugbot for commit 7cb9a08. Bugbot is set up for automated code reviews on this repo. Configure here.