YouTube link cannot be pasted if user is not part of "Embedded media post allowed groups"

AI-generated summary

A bug prevents users not in the “Embedded media post allowed groups” from pasting YouTube links, even though they should still be able to view onebox previews. Instead, they receive the error: “An error occurred: Sorry, you can’t embed media items in a post.” This occurs regardless of other embed or image download settings. The issue is reproducible by creating a new user on a hosted Discourse instance, removing them from the allowed groups, and attempting to paste a YouTube URL. The preview functionality appears to break because the system may be attempting to locally process the media preview, which is blocked for non-authorized users. The issue is classified as Medium severity since workarounds exist, but it disrupts expected behavior for basic link sharing. unknown_error notes that the problem affects any platform and is tied to the onebox rendering system’s interaction with media permissions.

Priority/Severity: Medium (annoying but has workarounds)

Platform: Any

Description: When a user is not a part of the “Embedded media post allowed groups” setting, they cannot upload any media. That is to be expected.

However, if they try to post any YouTube URL (like https://www.youtube.com/watch?v=L3Dp4oGkn3k), this also breaks the Onebox preview functionality (maybe it’s trying to cook the preview image into a local copy; not sure?), resulting in the error message: “An error occurred: Sorry, you can’t embed media items in a post.” every time.

Reproducible steps:

  1. Create a new free trial account on hosted Discourse
  2. Remove all non-admin users from Embedded media post allowed groups
  3. Create a new user and authorize/approve them
  4. Log in as that user and try to paste a YouTube link
  5. You should see the error "An error occurred: Sorry, you can't embed media items in a post."

This seems to happen regardless of the “Download remote images to local” and other embed/upload-related settings.