Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort Graph permissions with users ahead of groups #8465

Closed
chscott opened this issue Mar 21, 2025 · 23 comments
Closed

Sort Graph permissions with users ahead of groups #8465

chscott opened this issue Mar 21, 2025 · 23 comments
Labels
Support Contract Issues made for customers with support contracts
Milestone

Comments

@chscott
Copy link

chscott commented Mar 21, 2025

The associated forum post URL from https://forum.rclone.org

Discussed in email.

What is your current rclone version (output from rclone version)?

v1.69.1

What problem are you are trying to solve?

Graph has a quirk that manifests when all of these conditions apply:

  1. You are adding permissions for both a group and a user.
  2. The user is a member of the group.
  3. The permissions for the group and user are the same.
  4. You are adding the group permission before the user permission.

When all of the above are true, Graph indicates it has added the user permission, but it immediately drops it. For example:

2025/03/21 15:08:01 DEBUG : HTTP REQUEST (req 0xc0005bf040)
2025/03/21 15:08:01 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6FM5BTRUMZGVDKZS7JNQWOAEX3/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/21 15:08:01 DEBUG : HTTP RESPONSE (req 0xc0005bf040)
2025/03/21 15:08:01 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "displayName": "Reviewers Members"
                }
            }
        }
    ]
}

2025/03/21 15:08:01 DEBUG : HTTP REQUEST (req 0xc000bb1400)
2025/03/21 15:08:01 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6FM5BTRUMZGVDKZS7JNQWOAEX3/invite HTTP/1.1
{"recipients":[{"email":"angie.scott@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/21 15:08:02 DEBUG : HTTP RESPONSE (req 0xc000bb1400)
2025/03/21 15:08:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "angie@cdsconsulting.org",
                    "id": "4b9c56cb-83b3-4b1a-a66f-5e108a840bf4",
                    "displayName": "Angie Scott"
                }
            }
        }
    ]
}

2025/03/21 15:08:02 DEBUG : HTTP REQUEST (req 0xc0005bfe00)
2025/03/21 15:08:02 DEBUG : GET /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6FM5BTRUMZGVDKZS7JNQWOAEX3/permissions HTTP/1.1
2025/03/21 15:08:02 DEBUG : HTTP RESPONSE (req 0xc0005bfe00)
2025/03/21 15:08:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-')/items('01N4X3HM6FM5BTRUMZGVDKZS7JNQWOAEX3')/permissions",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "shareId": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "grantedToV2": {
                "group": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                },
                "siteUser": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "16",
                    "loginName": "c:0o.c|federateddirectoryclaimprovider|fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            }
        }, {
            "id": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "roles": ["owner"],
            "shareId": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "grantedToV2": {
                "user": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                },
                "siteUser": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "3",
                    "loginName": "i:0#.f|membership|chad.scott@cdsconsulting.org"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                }
            }
        }
    ]
}

How do you think rclone should be changed to solve that?

Attempt to apply user permissions before group permissions, which works around the issue. Note that you can force this to be the case today by returning a sorted permissions object from the mapper, but it's probably not obvious that this is required.

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
@chscott chscott added the Support Contract Issues made for customers with support contracts label Mar 21, 2025
@ncw
Copy link
Member

ncw commented Mar 21, 2025

Heads up @rclone/support - the "Support Contract" label was applied to this issue.

@chscott chscott changed the title Sort OneDrive permissions with users ahead of groups Sort Graph permissions with users ahead of groups Mar 21, 2025
@chscott
Copy link
Author

chscott commented Mar 21, 2025

@ncw This is what I emailed about earlier today. It appears to be a Graph issue and not a bug, and there is a workaround available. Still, I think it would be good to address this in rclone, as it could lead to loss of access in the following scenario:

  1. A user has individual and group permissions to a file.
  2. The user is removed from the group.
  3. The user no longer has access to the file because Graph dropped the individual permission.

Whether intentional or not, Graph is assuming group memberships are static, and that's anything but true in the real world.

ncw added a commit that referenced this issue Mar 26, 2025
Before this change, due to a quirk in Graph, User permissions could be
lost when applying permissions.

Fixes #8465
@ncw
Copy link
Member

ncw commented Mar 26, 2025

@chscott I had a go at ordering the permission updates so anything with a user in it comes first. I think this should fix the problem.

Can you give it a try?

v1.70.0-beta.8641.2af1e8f46.fix-8465-onedrive-metadata on branch fix-8465-onedrive-metadata (uploaded in 15-30 mins)

Thanks

@chscott
Copy link
Author

chscott commented Mar 26, 2025

@ncw The fix didn't work for me. Here's are two log excerpts. The first is with the fix and no changes on my side. The second is with v1.69.1 and a change on my side to sort the permissions that are returned to rclone.

2025/03/26 08:44:57 DEBUG : rclone: Version "v1.70.0-beta.8641.2af1e8f46.fix-8465-onedrive-metadata" starting with parameters
2025/03/26 08:44:59 DEBUG : Metadata mapper sent: 
{
	"SrcFs": "Source{UEqtu}:Test",
	"SrcFsType": "drive",
	"DstFs": "Target{VZpyf}:Test",
	"DstFsType": "onedrive",
	"Remote": "sample.txt",
	"Size": 22,
	"MimeType": "text/plain",
	"ModTime": "2025-03-26T13:41:56.572Z",
	"IsDir": false,
	"ID": "1vTdEO9GWMQzHJfN0l3Fcs5SZCvem0-5J",
	"Metadata": {
		"btime": "2025-03-25T20:30:38.560Z",
		"content-type": "text/plain",
		"copy-requires-writer-permission": "false",
		"mtime": "2025-03-26T13:41:56.572Z",
		"owner": "chad@cdsconsulting.co",
		"permissions": "[{\"emailAddress\":\"reviewers@cdsconsulting.co\",\"id\":\"09466358200964241419\",\"role\":\"writer\",\"type\":\"group\"},{\"emailAddress\":\"angie@cdsconsulting.co\",\"id\":\"14885772533033484759\",\"role\":\"writer\",\"type\":\"user\"},{\"emailAddress\":\"chad@cdsconsulting.co\",\"id\":\"09287294999424909072\",\"role\":\"owner\",\"type\":\"user\"}]",
		"starred": "false",
		"viewed-by-me": "true",
		"writers-can-share": "true"
	}
}
2025/03/26 08:44:59 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

2025/03/26 08:45:01 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:45:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "displayName": "Reviewers Members"
                }
            }
        }
    ]
}

2025/03/26 08:45:02 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52/invite HTTP/1.1
{"recipients":[{"email":"angie.scott@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:45:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "angie@cdsconsulting.org",
                    "id": "4b9c56cb-83b3-4b1a-a66f-5e108a840bf4",
                    "displayName": "Angie Scott"
                }
            }
        }
    ]
}

2025/03/26 08:45:02 DEBUG : GET /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52/permissions HTTP/1.1
2025/03/26 08:45:03 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-')/items('01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52')/permissions",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "shareId": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "grantedToV2": {
                "group": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                },
                "siteUser": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "16",
                    "loginName": "c:0o.c|federateddirectoryclaimprovider|fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            }
        }, {
            "id": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "roles": ["owner"],
            "shareId": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "grantedToV2": {
                "user": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                },
                "siteUser": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "3",
                    "loginName": "i:0#.f|membership|chad.scott@cdsconsulting.org"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                }
            }
        }
    ]
}
2025/03/26 08:52:36 DEBUG : rclone: Version "v1.69.1" starting with parameters 
2025/03/26 08:52:37 DEBUG : Metadata mapper sent: 
{
	"SrcFs": "Source{UEqtu}:Test",
	"SrcFsType": "drive",
	"DstFs": "Target{VZpyf}:Test",
	"DstFsType": "onedrive",
	"Remote": "sample.txt",
	"Size": 22,
	"MimeType": "text/plain",
	"ModTime": "2025-03-26T13:41:56.572Z",
	"IsDir": false,
	"ID": "1vTdEO9GWMQzHJfN0l3Fcs5SZCvem0-5J",
	"Metadata": {
		"btime": "2025-03-25T20:30:38.560Z",
		"content-type": "text/plain",
		"copy-requires-writer-permission": "false",
		"mtime": "2025-03-26T13:41:56.572Z",
		"owner": "chad@cdsconsulting.co",
		"permissions": "[{\"emailAddress\":\"reviewers@cdsconsulting.co\",\"id\":\"09466358200964241419\",\"role\":\"writer\",\"type\":\"group\"},{\"emailAddress\":\"angie@cdsconsulting.co\",\"id\":\"14885772533033484759\",\"role\":\"writer\",\"type\":\"user\"},{\"emailAddress\":\"chad@cdsconsulting.co\",\"id\":\"09287294999424909072\",\"role\":\"owner\",\"type\":\"user\"}]",
		"starred": "false",
		"viewed-by-me": "true",
		"writers-can-share": "true"
	}
}
2025/03/26 08:52:38 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

2025/03/26 08:52:40 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6YFBSNPFDSWJGZAWXNLGDPFDPO/invite HTTP/1.1
{"recipients":[{"email":"angie.scott@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:52:40 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "angie@cdsconsulting.org",
                    "id": "4b9c56cb-83b3-4b1a-a66f-5e108a840bf4",
                    "displayName": "Angie Scott"
                }
            }
        }
    ]
}

2025/03/26 08:52:40 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6YFBSNPFDSWJGZAWXNLGDPFDPO/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:52:41 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "displayName": "Reviewers Members"
                }
            }
        }
    ]
}

2025/03/26 08:52:41 DEBUG : GET /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6YFBSNPFDSWJGZAWXNLGDPFDPO/permissions HTTP/1.1
2025/03/26 08:52:41 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-')/items('01N4X3HM6YFBSNPFDSWJGZAWXNLGDPFDPO')/permissions",
    "value": [{
            "id": "aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc",
            "roles": ["write"],
            "shareId": "aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc",
            "grantedToV2": {
                "user": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Angie Scott",
                    "email": "angie@cdsconsulting.org",
                    "id": "4b9c56cb-83b3-4b1a-a66f-5e108a840bf4"
                },
                "siteUser": {
                    "displayName": "Angie Scott",
                    "email": "angie@cdsconsulting.org",
                    "id": "7",
                    "loginName": "i:0#.f|membership|angie.scott@cdsconsulting.org"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Angie Scott",
                    "email": "angie@cdsconsulting.org",
                    "id": "4b9c56cb-83b3-4b1a-a66f-5e108a840bf4"
                }
            }
        }, {
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "shareId": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "grantedToV2": {
                "group": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                },
                "siteUser": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "16",
                    "loginName": "c:0o.c|federateddirectoryclaimprovider|fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Reviewers Members",
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "id": "fec23cdf-a6de-4955-adeb-0179365e6b7b"
                }
            }
        }, {
            "id": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "roles": ["owner"],
            "shareId": "aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw",
            "grantedToV2": {
                "user": {
                    "@odata.type": "#microsoft.graph.sharePointIdentity",
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                },
                "siteUser": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "3",
                    "loginName": "i:0#.f|membership|chad.scott@cdsconsulting.org"
                }
            },
            "grantedTo": {
                "user": {
                    "displayName": "Chad Scott",
                    "email": "chad@cdsconsulting.org",
                    "id": "7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"
                }
            }
        }
    ]
}

@ncw
Copy link
Member

ncw commented Mar 26, 2025

@chscott

There is something which is puzzling me above. The POSTs have grantedTo not grantedToV2 like I would expect for a onedrive business. Is that what the metadata mapper is sending?

I think it probably needs to send grantedTo for onedrive personal and grantedToV2 for business, same for grantedToIdentities

@chscott
Copy link
Author

chscott commented Mar 26, 2025

The mapper is sending grantedToV2 in both cases. The first line in each pair below is from my code. The second is from rclone.

[1vTdEO9GWMQzHJfN0l3Fcs5SZCvem0-5J] Object to rclone: {"Metadata":{"permissions":"[{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

2025/03/26 08:44:59 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}
[1vTdEO9GWMQzHJfN0l3Fcs5SZCvem0-5J] Object to rclone: {"Metadata":{"permissions":"[{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

2025/03/26 08:52:38 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

@ncw
Copy link
Member

ncw commented Mar 31, 2025

Yes I see the mapper is sending grantedToV2 now, sorry.

What is confusing me is this which appears to send or receive grantedTo not grantedToV2. I'm not sure whether rclone is sending this or receiving this though.

Can you send me what rclone sent and what it received from onedrive for this call? I want to know if rclone sent grantedTo rather than grantedToV2 but I don't think that is in your log.

The reason I'm worried about this is that we sort the entries according to grantedTo or grantedToV2 depending on personal or business onedrive and if rclone is confused about which it should be using then the sorting will go wrong.

2025/03/26 08:45:01 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:45:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "displayName": "Reviewers Members"
                }
            }
        }
    ]
}

Thank you

@chscott
Copy link
Author

chscott commented Mar 31, 2025

@ncw Do you want data different from what is in #8465 (comment), or is that what you're looking for?

2025/03/26 08:44:59 DEBUG : Metadata mapper sent: 
{
	"SrcFs": "Source{UEqtu}:Test",
	"SrcFsType": "drive",
	"DstFs": "Target{VZpyf}:Test",
	"DstFsType": "onedrive",
	"Remote": "sample.txt",
	"Size": 22,
	"MimeType": "text/plain",
	"ModTime": "2025-03-26T13:41:56.572Z",
	"IsDir": false,
	"ID": "1vTdEO9GWMQzHJfN0l3Fcs5SZCvem0-5J",
	"Metadata": {
		"btime": "2025-03-25T20:30:38.560Z",
		"content-type": "text/plain",
		"copy-requires-writer-permission": "false",
		"mtime": "2025-03-26T13:41:56.572Z",
		"owner": "chad@cdsconsulting.co",
		"permissions": "[{\"emailAddress\":\"reviewers@cdsconsulting.co\",\"id\":\"09466358200964241419\",\"role\":\"writer\",\"type\":\"group\"},{\"emailAddress\":\"angie@cdsconsulting.co\",\"id\":\"14885772533033484759\",\"role\":\"writer\",\"type\":\"user\"},{\"emailAddress\":\"chad@cdsconsulting.co\",\"id\":\"09287294999424909072\",\"role\":\"owner\",\"type\":\"user\"}]",
		"starred": "false",
		"viewed-by-me": "true",
		"writers-can-share": "true"
	}
}
2025/03/26 08:44:59 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}},\"roles\":[\"write\"]},{\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}},\"roles\":[\"write\"]}]"}}

2025/03/26 08:45:01 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM36IPUADM7D4RGLAYEKM2E5HS52/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/03/26 08:45:02 DEBUG : HTTP/2.0 200 OK
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)",
    "value": [{
            "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi",
            "roles": ["write"],
            "grantedTo": {
                "user": {
                    "email": "reviewers@cdsconsultingllc.onmicrosoft.com",
                    "displayName": "Reviewers Members"
                }
            }
        }
    ]
}

@ncw
Copy link
Member

ncw commented Mar 31, 2025

I'd like to see what rclone sent if possible - I think (but I'm not 100% sure) that the above is what onedrive sent. That will need --dump bodies. Thanks

@chscott
Copy link
Author

chscott commented Apr 1, 2025

A full log is attached. I think the bit you're looking for is here:

2025/04/01 08:38:01 DEBUG : HTTP REQUEST (req 0xc000755180)
2025/04/01 08:38:01 DEBUG : POST /v1.0/drives/b!RI7jTE_7VEWvQfQFOGxQOFg6zGE89vBPg_ISUx_CLGNzm-ky8cLeQrzJ6fhJvcxd/items/014TQUZBEF3KFB577R5NBYOXBGZ4XPB5MR/invite HTTP/1.1
Host: graph.microsoft.com
User-Agent: ISV|Transend Corporation|TMCTools/1.0
Content-Length: 109
Authorization: Bearer REDACTED
Content-Type: application/json
Accept-Encoding: gzip

{"recipients":[{"email":"reviewers@transendtesting.onmicrosoft.com"}],"requireSignIn":true,"roles":["write"]}
2025/04/01 08:38:01 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2025/04/01 08:38:01 INFO  : 2025/04/01 08:38:01 -          22 B / 22 B, 100%, 5 B/s, ETA 0s
2025/04/01 08:38:03 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2025/04/01 08:38:03 DEBUG : HTTP RESPONSE (req 0xc000755180)
2025/04/01 08:38:03 DEBUG : HTTP/2.0 200 OK
Cache-Control: no-store, no-cache
Client-Request-Id: 16529a50-207d-4857-9076-f775d96f256d
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Date: Tue, 01 Apr 2025 13:38:02 GMT
Deprecation: Fri, 03 Sep 2021 23:59:59 GMT
Link: <https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=v1.0,Removal&from=2021-09-01&to=2021-10-01>;rel="deprecation";type="text/html"
Link: <https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=v1.0,Removal&from=2021-09-01&to=2021-10-01>;rel="deprecation";type="text/html"
Location: https://graph.microsoft.com
Odata-Version: 4.0
Request-Id: 16529a50-207d-4857-9076-f775d96f256d
Strict-Transport-Security: max-age=31536000
Sunset: Sun, 01 Oct 2023 23:59:59 GMT
Vary: Accept-Encoding
X-Ms-Ags-Diagnostic: {"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"SA2PEPF00002E05"}}

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)","value":[{"id":"Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ODVhZDY2ZTItYzJlYS00ZTMxLWEwNjQtMmU5NThlZGVjYzNm","roles":["write"],"grantedTo":{"user":{"email":"reviewers@transendtesting.onmicrosoft.com","displayName":"Reviewers Members"}}}]}

I believe what we are seeing was raised as an issue in https://learn.microsoft.com/en-us/answers/questions/1332382/microsoft-graph-api-drives-((drive-id))-items-((it, though I suspect grantedTo/grantedToV2 in the response is more of a quirk than the problem. The Microsoft answer linking to further discussion on that point doesn't seem related to the problem. I think the actual issue is described in Ed Freeman's response:

In my case, I deduced that it was because the user/group I was trying to assign permissions already had permissions on the item through some other means.

I think this is a bug on the Microsoft side, but the workaround of adding users before groups will help mitigate it, with no real downside I can think of. Presumably, there will still be cases that can be impacted, like groups that contain other groups.

chad@cdsconsulting.co.log

@ncw
Copy link
Member

ncw commented Apr 1, 2025

Thanks for that. I think you are right the grantedTo/grantedToV2 response is a quirk. I just checked the code and we don't actually use those returns for anything so I'm not too worried about it.

I've just been through the log you sent.

It looks like the user was sent before the group even though the metadata mapper sent them the other way round.

2025/04/01 08:38:01 DEBUG : POST /v1.0/drives/b!RI7jTE_7VEWvQfQFOGxQOFg6zGE89vBPg_ISUx_CLGNzm-ky8cLeQrzJ6fhJvcxd/items/014TQUZBEF3KFB577R5NBYOXBGZ4XPB5MR/invite HTTP/1.1
Host: graph.microsoft.com
User-Agent: ISV|Transend Corporation|TMCTools/1.0
Content-Length: 106
Authorization: Bearer REDACTED
Content-Type: application/json
Accept-Encoding: gzip

{
  "recipients": [
    {
      "email": "cuser2@transendtesting.onmicrosoft.com"
    }
  ],
  "requireSignIn": true,
  "roles": [
    "write"
  ]
}

is followed by

2025/04/01 08:38:01 DEBUG : POST /v1.0/drives/b!RI7jTE_7VEWvQfQFOGxQOFg6zGE89vBPg_ISUx_CLGNzm-ky8cLeQrzJ6fhJvcxd/items/014TQUZBEF3KFB577R5NBYOXBGZ4XPB5MR/invite HTTP/1.1
Host: graph.microsoft.com
User-Agent: ISV|Transend Corporation|TMCTools/1.0
Content-Length: 109
Authorization: Bearer REDACTED
Content-Type: application/json
Accept-Encoding: gzip

{
  "recipients": [
    {
      "email": "reviewers@transendtesting.onmicrosoft.com"
    }
  ],
  "requireSignIn": true,
  "roles": [
    "write"
  ]
}

So in this case the new code appears to have done its job.

Both the users are visible in the final output

Final output ```json { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21RI7jTE_7VEWvQfQFOGxQOFg6zGE89vBPg_ISUx_CLGNzm-ky8cLeQrzJ6fhJvcxd')/items('014TQUZBEF3KFB577R5NBYOXBGZ4XPB5MR')/permissions", "value": [ { "id": "aTowIy5mfG1lbWJlcnNoaXB8Y3VzZXIyQHRyYW5zZW5kdGVzdGluZy5vbm1pY3Jvc29mdC5jb20", "roles": [ "write" ], "shareId": "aTowIy5mfG1lbWJlcnNoaXB8Y3VzZXIyQHRyYW5zZW5kdGVzdGluZy5vbm1pY3Jvc29mdC5jb20", "grantedToV2": { "user": { "@odata.type": "#microsoft.graph.sharePointIdentity", "displayName": "Cloud User2", "email": "cuser2@transendtesting.onmicrosoft.com", "id": "57c26025-316f-4a71-a464-bf3adb0a6ac4" }, "siteUser": { "displayName": "Cloud User2", "email": "cuser2@transendtesting.onmicrosoft.com", "id": "7", "loginName": "i:0#.f|membership|cuser2@transendtesting.onmicrosoft.com" } }, "grantedTo": { "user": { "displayName": "Cloud User2", "email": "cuser2@transendtesting.onmicrosoft.com", "id": "57c26025-316f-4a71-a464-bf3adb0a6ac4" } } }, { "id": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ODVhZDY2ZTItYzJlYS00ZTMxLWEwNjQtMmU5NThlZGVjYzNm", "roles": [ "write" ], "shareId": "Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ODVhZDY2ZTItYzJlYS00ZTMxLWEwNjQtMmU5NThlZGVjYzNm", "grantedToV2": { "group": { "@odata.type": "#microsoft.graph.sharePointIdentity", "displayName": "Reviewers Members", "email": "reviewers@transendtesting.onmicrosoft.com", "id": "85ad66e2-c2ea-4e31-a064-2e958edecc3f" }, "siteUser": { "displayName": "Reviewers Members", "email": "reviewers@transendtesting.onmicrosoft.com", "id": "8", "loginName": "c:0o.c|federateddirectoryclaimprovider|85ad66e2-c2ea-4e31-a064-2e958edecc3f" } }, "grantedTo": { "user": { "displayName": "Reviewers Members", "email": "reviewers@transendtesting.onmicrosoft.com", "id": "85ad66e2-c2ea-4e31-a064-2e958edecc3f" } } }, { "id": "aTowIy5mfG1lbWJlcnNoaXB8Y3VzZXIxQHRyYW5zZW5kdGVzdGluZy5vbm1pY3Jvc29mdC5jb20", "roles": [ "owner" ], "shareId": "aTowIy5mfG1lbWJlcnNoaXB8Y3VzZXIxQHRyYW5zZW5kdGVzdGluZy5vbm1pY3Jvc29mdC5jb20", "grantedToV2": { "user": { "@odata.type": "#microsoft.graph.sharePointIdentity", "displayName": "Cloud User1", "email": "cuser1@transendtesting.onmicrosoft.com", "id": "e05ce5e6-bd01-4a63-981f-23719dc7e625" }, "siteUser": { "displayName": "Cloud User1", "email": "cuser1@transendtesting.onmicrosoft.com", "id": "3", "loginName": "i:0#.f|membership|cuser1@transendtesting.onmicrosoft.com" } }, "grantedTo": { "user": { "displayName": "Cloud User1", "email": "cuser1@transendtesting.onmicrosoft.com", "id": "e05ce5e6-bd01-4a63-981f-23719dc7e625" } } } ] } ```

What do you think @chscott did the new code work OK in this circumstance? If so why didn't it work above? 😕

@chscott
Copy link
Author

chscott commented Apr 4, 2025

In the most recent test, I was only trying to get the requests and responses, so I didn't back out my code change to return the permissions to Rclone in sorted (users, then groups) order. When I remove that change, the results I get are as in #8465 (comment).

ncw added a commit that referenced this issue Apr 8, 2025
Before this change, due to a quirk in Graph, User permissions could be
lost when applying permissions.

Fixes #8465
@ncw
Copy link
Member

ncw commented Apr 8, 2025

I'm struggling to work out why this isn't working, so here is a version with some more debugging

v1.70.0-beta.8658.ec2c1bab8.fix-8465-onedrive-metadata on branch fix-8465-onedrive-metadata (uploaded in 15-30 mins)

It should output ERROR logs which look like

2025/04/08 12:34:36 ERROR : perms before sort:
[
    {
        "id": "1",
        "grantedTo": {
            "user": {},
            "application": {},
            "device": {},
...

and

2025/04/08 12:34:36 ERROR : perms after sort:
[
    {
        "id": "2",
        "grantedToIdentities": [
            {
                "user": {
                    "displayName": "Alice"
                },
                "application": {},
                "device": {},
...

Can you have a go with that and send me the log? Hopefully that will clear up what is happening.

Thank you

@chscott
Copy link
Author

chscott commented Apr 8, 2025 via email

@ncw
Copy link
Member

ncw commented Apr 8, 2025

Sorry committed a bad test. Try this

v1.70.0-beta.8659.9d4c792da.fix-8465-onedrive-metadata on branch fix-8465-onedrive-metadata (uploaded in 15-30 mins)

@chscott
Copy link
Author

chscott commented Apr 8, 2025

Now I'm confused. I don't get the ERROR logs you mentioned, but this build worked, even with my changes reverted and the group still being added first.

log.zip

ncw added a commit that referenced this issue Apr 8, 2025
Before this change, due to a quirk in Graph, User permissions could be
lost when applying permissions.

Fixes #8465
@ncw
Copy link
Member

ncw commented Apr 8, 2025

Now I'm confused. I don't get the ERROR logs you mentioned

That would explain why it hasn't been working if the permissions ordering code isn't being called for some reason. Looking at the code I see there is a path (when there are only new permissions and no old ones) when they don't get ordered! That is an easy fix though

v1.70.0-beta.8674.9e62fa8c8.fix-8465-onedrive-metadata on branch fix-8465-onedrive-metadata (uploaded in 15-30 mins)

but this build worked, even with my changes reverted and the group still being added first.

Confusing indeed - the updates are sent in the wrong order but the result looks OK.

Do you think Microsoft have fixed this?

@chscott
Copy link
Author

chscott commented Apr 8, 2025

Do you think Microsoft have fixed this?

I looked for something in the Graph changelog, but I don't see anything that looks remotely close. Since there's a workaround of ensuring the mapper sends sorted permissions, I don't know that there's anything more we can do right now.

@ncw
Copy link
Member

ncw commented Apr 9, 2025

Do you think Microsoft have fixed this?

I looked for something in the Graph changelog, but I don't see anything that looks remotely close. Since there's a workaround of ensuring the mapper sends sorted permissions, I don't know that there's anything more we can do right now.

I think my fix above should sort the permissions properly if you have time to give it a go.

@chscott
Copy link
Author

chscott commented Apr 9, 2025

@ncw The latest fix did not work for me, as I still see the group sorted ahead of the user.

Version

2025/04/09 07:37:10 DEBUG : rclone: Version "v1.70.0-beta.8674.9e62fa8c8.fix-8465-onedrive-metadata" starting with parameters...

Data from mapper

2025/04/09 07:37:13 DEBUG : Metadata mapper received: 
{"Metadata":{"permissions":"[{\"roles\":[\"write\"],\"grantedToV2\":{\"group\":{\"id\":\"reviewers@cdsconsulting.org\"}}},{\"roles\":[\"write\"],\"grantedToV2\":{\"user\":{\"id\":\"angie.scott@cdsconsulting.org\"}}}]"}}

Requests to add permissions

2025/04/09 07:37:15 DEBUG : HTTP REQUEST (req 0xc0002d1e00)
2025/04/09 07:37:15 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6WTWTEBS5TNNDJXTQK5T66SAQM/invite HTTP/1.1
{"recipients":[{"email":"reviewers@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/04/09 07:37:15 DEBUG : HTTP RESPONSE (req 0xc0002d1e00)
2025/04/09 07:37:15 DEBUG : HTTP/2.0 200 OK
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)","value":[{"id":"Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi","roles":["write"],"grantedTo":{"user":{"email":"reviewers@cdsconsultingllc.onmicrosoft.com","displayName":"Reviewers Members"}}}]}

2025/04/09 07:37:15 DEBUG : HTTP REQUEST (req 0xc0001fb180)
2025/04/09 07:37:15 DEBUG : POST /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6WTWTEBS5TNNDJXTQK5T66SAQM/invite HTTP/1.1
{"recipients":[{"email":"angie.scott@cdsconsulting.org"}],"requireSignIn":true,"roles":["write"]}
2025/04/09 07:37:16 DEBUG : HTTP RESPONSE (req 0xc0001fb180)
2025/04/09 07:37:16 DEBUG : HTTP/2.0 200 OK
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.permission)","value":[{"id":"aTowIy5mfG1lbWJlcnNoaXB8YW5naWUuc2NvdHRAY2RzY29uc3VsdGluZy5vcmc","roles":["write"],"grantedTo":{"user":{"email":"angie@cdsconsulting.org","id":"4b9c56cb-83b3-4b1a-a66f-5e108a840bf4","displayName":"Angie Scott"}}}]}

Request to fetch permissions

2025/04/09 07:37:16 DEBUG : HTTP REQUEST (req 0xc0003768c0)
2025/04/09 07:37:16 DEBUG : GET /v1.0/drives/b!ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-/items/01N4X3HM6WTWTEBS5TNNDJXTQK5T66SAQM/permissions HTTP/1.1

2025/04/09 07:37:16 DEBUG : HTTP RESPONSE (req 0xc0003768c0)
2025/04/09 07:37:16 DEBUG : HTTP/2.0 200 OK
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives('b%21ssbqQHJ0v0Ki4mBGkrRBXWvDWPc3piNIl8WI29g4XaD8jOMrJ7J6RKVhFAqRVq5-')/items('01N4X3HM6WTWTEBS5TNNDJXTQK5T66SAQM')/permissions","value":[{"id":"Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi","roles":["write"],"shareId":"Yzowby5jfGZlZGVyYXRlZGRpcmVjdG9yeWNsYWltcHJvdmlkZXJ8ZmVjMjNjZGYtYTZkZS00OTU1LWFkZWItMDE3OTM2NWU2Yjdi","grantedToV2":{"group":{"@odata.type":"#microsoft.graph.sharePointIdentity","displayName":"Reviewers Members","email":"reviewers@cdsconsultingllc.onmicrosoft.com","id":"fec23cdf-a6de-4955-adeb-0179365e6b7b"},"siteUser":{"displayName":"Reviewers Members","email":"reviewers@cdsconsultingllc.onmicrosoft.com","id":"16","loginName":"c:0o.c|federateddirectoryclaimprovider|fec23cdf-a6de-4955-adeb-0179365e6b7b"}},"grantedTo":{"user":{"displayName":"Reviewers Members","email":"reviewers@cdsconsultingllc.onmicrosoft.com","id":"fec23cdf-a6de-4955-adeb-0179365e6b7b"}}},{"id":"aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw","roles":["owner"],"shareId":"aTowIy5mfG1lbWJlcnNoaXB8Y2hhZC5zY290dEBjZHNjb25zdWx0aW5nLm9yZw","grantedToV2":{"user":{"@odata.type":"#microsoft.graph.sharePointIdentity","displayName":"Chad Scott","email":"chad@cdsconsulting.org","id":"7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"},"siteUser":{"displayName":"Chad Scott","email":"chad@cdsconsulting.org","id":"3","loginName":"i:0#.f|membership|chad.scott@cdsconsulting.org"}},"grantedTo":{"user":{"displayName":"Chad Scott","email":"chad@cdsconsulting.org","id":"7ecdcdf3-e69a-4194-8ad8-e290ea289fd5"}}}]}

log.zip

ncw added a commit that referenced this issue Apr 10, 2025
Before this change, due to a quirk in Graph, User permissions could be
lost when applying permissions.

Fixes #8465
@ncw
Copy link
Member

ncw commented Apr 10, 2025

Thanks for that @chscott

I can see from the logs that the sorting isn't working. I figured out why - it is because I was ignoring the ID field in the permissions to detect whether they were set or not, and that is the only one you are setting!

I've fixed this now. I've tested this with your data so I think it should work for you now.

v1.70.0-beta.8711.96957a177.fix-8465-onedrive-metadata on branch fix-8465-onedrive-metadata (uploaded in 15-30 mins)

@chscott
Copy link
Author

chscott commented Apr 10, 2025

Looks good, @ncw. I see this in the log, and the user permission is added to the file. I think we can close this as resolved.

2025/04/10 08:31:25 ERROR : perms before sort:
[
    {
        "id": "",
        "grantedToV2": {
            "user": {},
            "application": {},
            "device": {},
            "group": {
                "id": "reviewers@cdsconsulting.org"
            },
            "siteGroup": {},
            "siteUser": {}
        },
        "roles": [
            "write"
        ]
    },
    {
        "id": "",
        "grantedToV2": {
            "user": {
                "id": "angie.scott@cdsconsulting.org"
            },
            "application": {},
            "device": {},
            "group": {},
            "siteGroup": {},
            "siteUser": {}
        },
        "roles": [
            "write"
        ]
    }
]
2025/04/10 08:31:25 ERROR : perms after sort:
[
    {
        "id": "",
        "grantedToV2": {
            "user": {
                "id": "angie.scott@cdsconsulting.org"
            },
            "application": {},
            "device": {},
            "group": {},
            "siteGroup": {},
            "siteUser": {}
        },
        "roles": [
            "write"
        ]
    },
    {
        "id": "",
        "grantedToV2": {
            "user": {},
            "application": {},
            "device": {},
            "group": {
                "id": "reviewers@cdsconsulting.org"
            },
            "siteGroup": {},
            "siteUser": {}
        },
        "roles": [
            "write"
        ]
    }
]

@ncw ncw closed this as completed in e0c99d6 Apr 11, 2025
@ncw
Copy link
Member

ncw commented Apr 11, 2025

Thanks for testing @chscott - glad we got there in the end.

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.70

It will be in this and subsequent betas v1.70.0-beta.8714.e0c99d620

@ncw ncw added this to the v1.70 milestone Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Contract Issues made for customers with support contracts
Projects
None yet
Development

No branches or pull requests

2 participants