Skip to content

FIX: Respect blocked_onebox_domains for Twitter/X and handle empty oneboxes#38868

Merged
ZogStriP merged 1 commit intomainfrom
fix/twitter-onebox-blocking-and-empty-fallback
Mar 25, 2026
Merged

FIX: Respect blocked_onebox_domains for Twitter/X and handle empty oneboxes#38868
ZogStriP merged 1 commit intomainfrom
fix/twitter-onebox-blocking-and-empty-fallback

Conversation

@ZogStriP
Copy link
Member

Two issues with Twitter/X oneboxes:

  1. Adding x.com or twitter.com to blocked_onebox_domains had no effect. In FinalDestination#resolve, domains in the ignore_redirects list (which includes x.com, twitter.com, youtube.com, etc.) trigger an early return with :resolved status before blocked_domain? is ever checked. This made it impossible to block oneboxes for any of these domains. The fix adds the blocked domain check before the ignore_redirects shortcut in resolve().

  2. When X/Twitter returns no useful Open Graph metadata (which is the current real-world behavior without API credentials), the onebox rendered an empty shell — an <aside> with blank title, empty tweet div, and no timestamp. TwitterStatusOnebox had no field validation unlike other engines (e.g. AmazonOnebox). The fix adds a verified_data method that requires title and tweet to be present, returning empty HTML when they're missing. This causes Discourse to fall back to a plain link instead of rendering a broken onebox.

https://meta.discourse.org/t/397516

…oneboxes

Two issues with Twitter/X oneboxes:

1. Adding `x.com` or `twitter.com` to `blocked_onebox_domains` had no
   effect. In `FinalDestination#resolve`, domains in the `ignore_redirects`
   list (which includes x.com, twitter.com, youtube.com, etc.) trigger an
   early return with `:resolved` status before `blocked_domain?` is ever
   checked. This made it impossible to block oneboxes for any of these
   domains. The fix adds the blocked domain check before the
   `ignore_redirects` shortcut in `resolve()`.

2. When X/Twitter returns no useful Open Graph metadata (which is the
   current real-world behavior without API credentials), the onebox
   rendered an empty shell — an `<aside>` with blank title, empty tweet
   div, and no timestamp. `TwitterStatusOnebox` had no field validation
   unlike other engines (e.g. `AmazonOnebox`). The fix adds a
   `verified_data` method that requires `title` and `tweet` to be present,
   returning empty HTML when they're missing. This causes Discourse to
   fall back to a plain link instead of rendering a broken onebox.

https://meta.discourse.org/t/397516
@pmusaraj
Copy link
Contributor

Spec failure looks like a flake.

@ZogStriP ZogStriP merged commit 4886c59 into main Mar 25, 2026
28 of 29 checks passed
@ZogStriP ZogStriP deleted the fix/twitter-onebox-blocking-and-empty-fallback branch March 25, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants