sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

CSOM Microsoft.SharePoint.Client.Web throws exception when loading ServerRelativePath.

Open raghus-axiomint opened this issue 1 year ago • 11 comments

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

  • [ ] 💥 Internet Explorer
  • [ ] 💥 Microsoft Edge
  • [ ] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [x] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

No response

Describe the bug / error

We recently have been experiencing an issue when loading the ServerRelativePath property of the Web object. We understand that web server update from version 16.0.25722.12007 to 16.0.25729.12006 broke this (ServerRelativePath) property. Microsoft's workaround to use Web.RootFolder.ServerRelativePath property is not foolproof because the access fails if the user does not have sufficient permissions. Unfortunately, Web.ServerRelativeUrl is not a solution either since it doesn't support paths containing % and # characters (refer to https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/supporting-and-in-file-and-folder-with-the-resourcepath-api).

Steps to reproduce

  1. Create a SharePoint context with any URL.
  2. Try to retrieve the Web.ServerRelativePath property.
  3. Notice the exception that comes up when you try to retrieve the property.

Expected behavior

There shouldn't be any exceptions, and the property should be retrieved.

raghus-axiomint avatar Feb 18 '25 14:02 raghus-axiomint

Hello @raghus-axiomint, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

ChetanSharma-msft avatar Feb 19 '25 11:02 ChetanSharma-msft

Hello @raghus-axiomint, Could you share the exact exception that occurs when you attempt to retrieve the Web.ServerRelativePath property? It would be helpful to see the exact sample code you're using to retrieve this property.

Ashlesha-MSFT avatar Feb 20 '25 04:02 Ashlesha-MSFT

@Ashlesha-MSFT Please find below the exception and stack trace.

Exception: Microsoft.SharePoint.Client.ServerException: 'Field or property "ServerRelativePath" does not exist.'

Stack Trace: at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() at TestProject.SharePoint.SharePointExtensions.<>c__DisplayClass1_0.b__0(ClientRequestWrapper wrapper) in D:\Projects\TestProject\SharePoint\SharePointExtensions.cs:line 101 at Axiom.Net.SharePoint.SharePointExtensions.ExecuteWithRetry(Action`1 executeAction, String url, String tag, String callerName) in D:\Projects\TestProject\SharePoint\SharePointExtensions.cs:line 146 Sample Code: // GetClientContext method is an internal method that returns the "ClientContext" object. using (var context = GetClientContext(url, siteCollection)) { context.Load(context.Web, site => site.ServerRelativePath, site => site.Title); // Server exception is being thrown when completing the request context.ExecuteQueryWithRetry(); }

raghus-axiomint avatar Feb 20 '25 13:02 raghus-axiomint

The bug can also be easily triggered using PnP PowerShell:

Connect-PnPOnline [...]

# Check server version
(Get-PnPContext).ServerVersion

# Get web and property
$web = Get-PnPWeb
$serverRelativePath = Get-PnPProperty -ClientObject $web -Property "ServerRelativePath"

I was able to pinpoint it to the change of the server version from 16.0.25722.12007 (working fine) to 16.0.25729.12006 (broken) that was rolling out ~10 days ago.

This MS Learn Q&A discussion is on the same issue: https://learn.microsoft.com/en-us/answers/questions/2156350/csom-microsoft-sharepoint-client-web-throws-except

fheinicke avatar Feb 20 '25 13:02 fheinicke

@raghus-axiomint, right @fheinicke server version update, broken the "serverRelativePath" property $serverRelativePath = Get-PnPProperty -ClientObject $web -Property "ServerRelativePath"

Get-PnPProperty: Field or property "ServerRelativePath" does not exist.

Ashlesha-MSFT avatar Feb 24 '25 09:02 Ashlesha-MSFT

@Ashlesha-MSFT We're aware that the update from server version 16.0.25722.12007 to 16.0.25729.1200 broke the property. That's in this issue's description too. What we want to know now is, what is Microsoft doing to fix this issue?

raghus-axiomint avatar Feb 24 '25 16:02 raghus-axiomint

@raghus-axiomint, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it.

Ashlesha-MSFT avatar Mar 03 '25 12:03 Ashlesha-MSFT

@Ashlesha-MSFT What's the typical SLA (Service Level Agreement) to resolve a bug like this that has impacted thousands of users worldwide?

raghus-axiomint avatar Mar 03 '25 13:03 raghus-axiomint

I had a support ticket open for this case for a while and was notified today that the product team deployed a fix for the issue. In my tests on multiple tenants, the bug is fixed in both server versions that I now see (16.0.25812.12010 and 16.0.25812.12011).

fheinicke avatar Mar 06 '25 09:03 fheinicke

@raghus-axiomint , @fheinicke I too have observed that ServerRalativePath property is working now. Image

Ashlesha-MSFT avatar Mar 10 '25 05:03 Ashlesha-MSFT

We are closing this issue for now. If the problem persists, feel free to reopen it or open a new one.

Ashlesha-MSFT avatar Jul 15 '25 07:07 Ashlesha-MSFT