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

Values retrieved from SharePoint Online tenant properties (via. REST API) are not consistent

Open devangbhavsar89 opened this issue 3 years ago • 2 comments

Target SharePoint environment

SharePoint Online

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

SharePoint REST API

Describe the bug / error

For a given tenant property which has been updated multiple times, whenever we try to retrieve a tenant property using REST API, it returns different output (including previously stored values).

In other words, multiple requests to https://<tenant>.sharepoint.com/sites/<web>/_api/web/GetStorageEntity('key') REST API yields inconsistent results.

Additional Observation

  • This problem occurs even after we disabled browser-level caching of Network requests.
  • It should be noted that this issue occurs only when you use REST API to retrieve tenant properties. Using Get-PnPStorageEntity cmdlet, it always gives me the latest (correct) value.

Perhaps could this be an issue with multiple front-end servers processing my request? And the fact that tenant properties are cached on front-end servers for optimization. So whenever it's value is updated, it is not synced instantaneously across available servers and hence the issue.

Steps to reproduce

  1. Connect to your SharePoint Online tenant using PnP PowerShell.
  2. Set tenant property using PnP cmdlet. Set-PnPStorageEntity -Key "Country" -Value "Finland"
  3. Log-in to your tenant in browser and open a new tab and enter the following URL and check the response: https://<tenant>.sharepoint.com/sites/<web>/_api/web/GetStorageEntity('Country')
  4. Then update the tenant property with a different value using PnP cmdlet. Set-PnPStorageEntity -Key "Country" -Value "India"
  5. Refresh the URL (mentioned above in step-4) multiple times and notice the inconsistency in values yielded by the REST API. Sometimes it returns India, other times Finland. And at times even null is returned.

Expected behavior

  • Tenant properties yielded by REST API are consistent.
  • It always returns the latest value of the requested tenant property.

devangbhavsar89 avatar May 24 '22 07:05 devangbhavsar89

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar May 24 '22 07:05 ghost

Hi, just adding that I'm impacted by this issue too - I was expecting consistent results when using the REST API but I see now that it returns old values as described by @devangbhavsar89

Are there plans to fix this? It would also be good to get some info on how long the issue occurs before the "latest" value is reflected across all servers/nodes or whatever is caching the old values.

adamd9 avatar Oct 17 '22 05:10 adamd9

Bump. This is still an issue. @adamd9 @devangbhavsar89 As a workaround I'm using storageentitiesindex web property. It returns a JSON of all properties set for current web.

Careful with this, because it will only work for current web and will not return all properties if they are set on the different site with site app catalog, you might need to run it against global app catalog.

fetch("<tenant>/sites/<site>/_api/web/AllProperties?$select=storageentitiesindex", {
  "headers": {
    "accept": "application/json",
  },
  "method": "GET",
  "mode": "cors",
  "credentials": "include"
});

https://learn.microsoft.com/en-us/sharepoint/dev/spfx/tenant-properties?tabs=sprest#list-tenant-properties

SharePickle avatar Dec 08 '22 12:12 SharePickle

Thanks for the workaround @SharePickle!

adamd9 avatar Dec 10 '22 20:12 adamd9

Any progress on that? Still an issue and the workaround is not the best option.

SharePickle avatar Jan 22 '24 12:01 SharePickle