Umbraco 17: IPublishedContentQuery.MediaAtRoot() returns empty (ContentAtRoot works)

Hi everyone,
I’m running into something odd in Umbraco 17: IPublishedContentQuery.MediaAtRoot() always returns an empty enumerable for me, while ContentAtRoot() returns items as expected.

Environment

  • Umbraco CMS: 17.1

  • Using published APIs (IPublishedContentQuery)

What I’m doing

var contentRoots = publishedContentQuery.ContentAtRoot(); // returns items ✅
var mediaRoots   = publishedContentQuery.MediaAtRoot();   // empty ❌

There are media items/folders at the media root in the backoffice.

Expected

MediaAtRoot() should return the published media root items/folders (similar to ContentAtRoot() but for media).

Actual

MediaAtRoot() returns an empty result.

Possible cause (from source)

From what I can see in the Umbraco source, MediaAtRoot() delegates to ItemsAtRoot(_publishedMediaCache), and ItemsAtRoot(...) appears to fetch root keys via IDocumentNavigationQueryService (document/content root keys). If that’s the case, the keys won’t match media IDs and the media cache lookups would return null, leading to an empty result.

Source reference (example for release-17.0.0):
https://raw.githubusercontent.com/umbraco/Umbraco-CMS/release-17.0.0/src/Umbraco.Infrastructure/PublishedContentQuery.cs

Questions

  1. Can anyone reproduce this on the latest Umbraco 17.x patch?

  2. Is this a known issue / already tracked somewhere?

  3. If it’s a bug, what’s the preferred minimal repro to include in a GitHub issue?

Thanks!

Umbraco 17.2 was released earlier today, not sure if you have checked if the same issues exists on the current version