Examine: Fix DocumentUrlService not initialized during Examine indexing after package upgrade#22243
Merged
AndyButland merged 2 commits intomainfrom Mar 25, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an upgrade/startup race where Examine indexing can run before DocumentUrlService is initialized, causing InvalidOperationException during value set building. The change ensures URL segments can still be produced during indexing by falling back to direct segment computation when the service cache is unavailable.
Changes:
- Guard
IDocumentUrlService.GetUrlSegment(...)calls behindIsInitializedchecks during Examine value set creation. - Add a fallback path that computes URL segments directly from
IContentwhen the document URL cache is not ready. - Use
DocumentUrlServicefor variant URL segments when initialized (instead of always bypassing it).
DocumentUrlService not initialized during Examine indexing after package upgrade
Zeegaan
approved these changes
Mar 24, 2026
Member
Zeegaan
left a comment
There was a problem hiding this comment.
Can reproduce this easily, and this pr fies it 🚀
This is pointed at main, but it's probably worth including in 17.3 🤔
Contributor
Author
|
Thanks @Zeegaan - I agree, will cherry-pick it over. |
AndyButland
added a commit
that referenced
this pull request
Mar 25, 2026
…xing after package upgrade (#22243) * Revert to segment retrieval from content when document URL service isn't initialised. * Add tests for ContentValueSetBuilder.
This was referenced Apr 2, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses an issue I found in testing:
dotnet add package CleanThis error is seeing in the logs:
It appears to be a race condition where
ContentValueSetBuildercallsDocumentUrlService.GetUrlSegment()before the service is initialized, causing anInvalidOperationExceptionduring Examine indexing after a package upgrade,Root Cause
When Umbraco restarts with pending package migrations,
DocumentUrlServiceInitializerNotificationHandlerskips initialization because the runtime level isUpgrade. Meanwhile,QueuedHostedServiceis already running and can process deferred Examine indexing tasks queued during/after migration execution — beforeDocumentUrlService.InitAsync()is ever called (either viaContentCacheRefresher.RefreshAllor the post-migrationUmbracoApplicationStartingNotification).Fix
Guard
DocumentUrlServicecalls inContentValueSetBuilderwith anIsInitializedcheck. When not initialized, fall back to computing the URL segment directly from the content using the sameGetUrlSegmentextension method thatDocumentUrlServiceitself uses internally to populate its cache.This fallback was already used for the variant path, so I've also aligned that to use the
DocumentUrlServicewhen it can.Testing
Use the NuGet packages built from this PR in a local feed. Verify that the issue no longer occurs.
AB: I've done this.