Minor caching bug with Item.Paths.GetPath() in Sitecore 8

Search for a command to run...

No comments yet. Be the first to comment.
Polly is great library for easily configuring different kinds of policies around code execution, be it retry, circuit breaker, caching or lots of other things. It's probably most often used around HTTP requests. If you haven't heard about it you defi...

This is part 2 of my series on unit testing in .NET (C#) and will be about my conventions regarding naming unit tests, how to structure them and which parts to test. And lastly I will help you increase readability of assertions and potential error me...

I feel like unit testing is very important and very beneficial in a lot of ways. It helps with not breaking existing functionality and thereby also making you more confident in changing code without fear of breaking important stuff. Often it also mak...

I've been working with Swagger through NSwag a lot recently and also needed to get it to work when hidden behind a reverse proxy - i.e. another service forwarding a request to the service exposing the Swagger UI. Some of the issues I've had along the...

The other day I was writing a unit test to verify what was supposed to happen when a Task would throw an exception when awaited. It wasn't as straight forward as I first assumed, but I quickly found this Stack Overflow post that helped me: https://st...

The Item.Paths property returns an ItemPath and with Sitecore 8 they changed the implementation of ItemPath.GetPath(string from, string separator, ItemPathType type) to use caching internally. However the separator is not part of the caching key, only the item it self and the ItemPathType.
This of course means that the separator used the first time is then cached as part of the path and consecutive calls for this item - until the cache is cleared - will return the cached path, ignoring the specified separator.
It's probably not the most used feature, I ran into this issue when upgrading some legacy code that used this method.
The bug exists in 8.2 Update-2 rev.161221 and has been registered with Sitecore Support with reference number 141772.
They don't currently have a fix, but you could just use something like Item.Paths.FullPath.Replace('/', '|') instead if you need another separator.