# Incorrect or failing oneboxes for links to other discourse instances

**URL:** https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351
**Category:** Bug
**Created:** [2 Agosto 2017, 10:23pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351 "2017-08-02T22:23:55Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [2 Agosto 2017, 10:23pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/1 "2017-08-02T22:23:55Z")

</div>

Something seems to have been broken in a recent upgrade of the oneboxing engine. For example, this URL

`https://meta.discourse.org/t/new-users-arent-starting-the-discobot-tutorial/62995/9?u=tophee`

used to be rendered like this on a discourse instance that is not meta:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/2/32ead27ff15e5fb5abe7b9555112dff8dd6f0ef1.png)

Now it is rendered like this:

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/c/3cf42304f528521f41bbd5ee7d2acd05ae51457d.png)

Never mind the different colour scheme. It’s the text that is different. In the older version, the text of the post being referred to is shown, now it’s the text of the OP (although I also wonder why the user avatar is missing in both cases, but that would be an older bug).

To be more precise: the old image is from my forum which is currently still on v1.9.0.beta4 +61, the new one is from feverbee (as of today) but I have also tried it on another freshly installed instance.

Next one is `https://meta.discourse.org/t/change-to-dd-mmm-mmm-yy-for-post-dates/13625/35?u=tophee` which used to render like this:

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/a/9abe98914c887cbf3038e0f128f5832c1ede45f3.png)

but now comes out like this

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/9/49e13ecadae59d0aee3b3525c7f01669bbdc3d1b.png)

Like in the first example, the text is now the OP’s text but - strangely, now also the image is a different one (first image in post instead of user avatar).

Finally, this URL `https://meta.discourse.org/t/discourse-narrative-bot-beta-feedback/58621/254?u=tophee` used to render like this:

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/3/d313ffef816d6be1764ddf4587440b721c647d31.png)

but now it fails entirely to be oneboxed:

![image](https://global.discourse-cdn.com/meta/original/3X/c/d/cdac590066511099335b861808999ba62a5b1eb6.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2 Agosto 2017, 10:30pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/2 "2017-08-02T22:30:14Z")

</div>

hmm…

```plaintext
https://try.discourse.org/t/how-can-i-make-a-post-wiki/325

```

> **[How can I make a post Wiki?](https://try.discourse.org/t/how-can-i-make-a-post-wiki/325)**
>
> Discourse now supports making a post Wiki! By default, Trust Level 3 users can make a post Wiki. You will find the button to make a post Wiki by clicking on the admin wrench under the desired post. Click on admin wrench under the desired post ...

and [How can I make a post Wiki? - discourse - Discourse Demo](https://try.discourse.org/t/how-can-i-make-a-post-wiki/325)

```plaintext
and https://try.discourse.org/t/how-can-i-make-a-post-wiki/325

```

Seem to work here…

> **[A bear, however hard he tries, grows tubby without exercise](https://try.discourse.org/t/a-bear-however-hard-he-tries-grows-tubby-without-exercise/48/3?u=samsaffron)**
>
> The combination of a treadmill (not a desk, just a treadmill), an iPad and video streaming has been great for me. It’s the only exercise I’ve been able to sustain for longer than a couple of weeks in the past 20 years. I walk 3.5 miles every day...

```plaintext
https://try.discourse.org/t/a-bear-however-hard-he-tries-grows-tubby-without-exercise/48/3?u=samsaffron

```

😕 can you repro whatever issue you have with try.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [2 Agosto 2017, 10:42pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/3 "2017-08-02T22:42:20Z")

</div>

> [@sam](#):
>
> can you repro whatever issue you have with try.

Yes. Here you go: [https://try.discourse.org/t/testing-oneboxing-bug/791](https://try.discourse.org/t/testing-oneboxing-bug/791)

And for future generations:

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/f/df891da0d298730f82cf64f49ed7058376f74785.png)

But just to be clear: what exactly is the expected behaviour when it comes to the images in the onebox? When should I expect the user avatar and when the first image in the post? (Personally, I think I’d always like to see the user avatar…)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2 Agosto 2017, 10:48pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/4 "2017-08-02T22:48:44Z")

</div>

Oh wait – you’re right, this is wrong. @techapj this is quite bad, if it is off by one, or affected by deletions. Please make this a priority.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2 Agosto 2017, 10:48pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/5 "2017-08-02T22:48:57Z")

</div>

255 is a deleted post so it may be somehow related @techAPJ can you have look to see if there is an off by one error or something

The only weird I see is that 254 is not one boxing @codinghorror

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [3 Agosto 2017, 2:08am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/6 "2017-08-03T02:08:28Z")

</div>

```plaintext
https://meta.discourse.org/t/discourse-narrative-bot-beta-feedback/58621/254?u=tophee

```

has a canonical link:

```plaintext
https://meta.discourse.org/t/discourse-narrative-bot-beta-feedback/58621?page=13

```

which renders whitepage.. looking more into it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [3 Agosto 2017, 2:10am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/7 "2017-08-03T02:10:01Z")

</div>

That does not look correct, maybe for crawler only. In which case you need to ignore that for Discourse instances.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [3 Agosto 2017, 5:07am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/8 "2017-08-03T05:07:02Z")

</div>

> [@sam](#):
>
> The only weird I see is that 254 is not one boxing

How about the text in the oneboxes not being from the referenced posts?

And how about the inconsistent rendering of images?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [3 Agosto 2017, 5:16am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/9 "2017-08-03T05:16:29Z")

</div>

This is because the open graph data is now coming from canonical links (read more about this change [here](https://meta.discourse.org/t/imdb-embeds-broken-on-other-sites/35317/39)). For example:

```plaintext
https://meta.discourse.org/t/change-to-dd-mmm-mmm-yy-for-post-dates/13625/35?u=tophee

```

has a canonical link

```plaintext
https://meta.discourse.org/t/change-to-dd-mmm-mmm-yy-for-post-dates/13625?page=2

```

Now when you will see `og:{xyz}` data for the canonical link above you will understand why the text and image is different from that of linked post.

That said, I agree that the text and image shown in onebox should be of the linked post (instead of the page specific post as seen in above example). I am working on a fix for it right now.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [3 Agosto 2017, 5:28am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/10 "2017-08-03T05:28:46Z")

</div>

> [@techAPJ](#):
>
> page specific post

I didn’t even know that discourse still does pagination in the background, but as I think about it, I see that, unless you want to load each post individually, pagination is needed.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [3 Agosto 2017, 7:08am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/11 "2017-08-03T07:08:10Z")

</div>

> [@tophee](#):
>
> I didn’t even know that discourse still does pagination in the background, but as I think about it, I see that, unless you want to load each post individually, pagination is needed.

The pagination shown here is only for non-Javascript user-agents (like web crawlers). The javascript interface works differently, which is how/why posts can update live on screen.

But the oneboxer is a non-Javascript user-agent.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [3 Agosto 2017, 8:38am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/12 "2017-08-03T08:38:04Z")

</div>

> [@codinghorror](#):
>
> you need to ignore that for Discourse instances.

> [@techAPJ](#):
>
> the text and image shown in onebox should be of the linked post

Fixed via:

[https://github.com/discourse/onebox/commit/70aa8d5961b6e742c424d25fed6d4615a0d7e42b](https://github.com/discourse/onebox/commit/70aa8d5961b6e742c424d25fed6d4615a0d7e42b)

> [@tophee](#):
>
> what exactly is the expected behaviour when it comes to the images in the onebox? When should I expect the user avatar and when the first image in the post?

Okay, let me try to explain.

### Topic body (first post)

If the first post contains an image, onebox will show that image.

> **[Bear walks into home, then poops and leaves](https://bbs.boingboing.net/t/bear-walks-into-home-then-poops-and-leaves/105061)**
>
> And here I thought they shit in the woods.

If the first post does not have any image it will fall back to `default_opengraph_image_url` setting (more detail [here](https://meta.discourse.org/t/facebook-opengraph-images-not-working-on-the-homepage/46086/22)).

> **[Welcome to BBS, our new discussion boards](https://bbs.boingboing.net/t/welcome-to-bbs-our-new-discussion-boards/31)**
>
> Boing Boing’s had plain old blog comments since 2007. It’s time for something bigger and better. So welcome to BBS, our new discussion boards! The boards run on Discourse, a completely new forum system created by Jeff Atwood, of Stack Exchange...

### Topic reply (random post in a topic)

If the post contains image, onebox will show that image.

> **[Bear walks into home, then poops and leaves](https://bbs.boingboing.net/t/bear-walks-into-home-then-poops-and-leaves/105061/3)**
>
> At least it wasn’t pandas; they’re downright criminal with their antics. Sorry; I had to.

If the post does not contain any image, onebox will show user (poster) avatar.

> **[Bear walks into home, then poops and leaves](https://bbs.boingboing.net/t/bear-walks-into-home-then-poops-and-leaves/105061/6)**
>
> /End-Of-Thread

I hope this clarifies the onebox behaviour.

Also note that this behaviour will be consistent across all the sites that uses OpenGraph tags to fetch data.

* * *

The above oneboxes also verifies that fix is working.. 😊

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [3 Agosto 2017, 9:00am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/13 "2017-08-03T09:00:27Z")

</div>

Thanks for the explanation (and the quick fix, of course!). That’s almost worth a faq-material tag, but we don’t want to overdo things…

> [@techAPJ](#):
>
> If the post contains image, onebox will show that image.

Perhaps it would be a good idea to have onebox ignore small images like this one from becoming the featured image?

[https://global.discourse-cdn.com/meta/images/font-awesome-ellipsis.png](https://global.discourse-cdn.com/meta/images/font-awesome-ellipsis.png)

Hm, as I paste this, I realize that the actual image file is not as tiny as it seems when it’s shown like this: ![](https://sea3.discourse-cdn.com/meta/images/font-awesome-ellipsis.png), but nonetheless, do you see what I mean?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [3 Agosto 2017, 9:47am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/14 "2017-08-03T09:47:03Z")

</div>

> [@tophee](#):
>
> Hm, as I paste this, I realize that the actual image file is not as tiny as it seems when it’s shown like this: , but nonetheless, do you see what I mean?

Yes, I see what you mean, but fixing this will not be a trivial change.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [11 Agosto 2017, 4:29pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/16 "2017-08-11T16:29:06Z")

</div>

> WhitelistedGenericOnebox.probable\_discourse(URI(url))

I am not a huge fan of this, what I would recommend is adding some sort of custom open graph tag that tells us not to follow canonical. That way any site owner can opt for this behavior not only Discourse instances. Hitting the URL with a regex is fragile and will eventually break, I can guarantee that 100%

> <https://github.com/discourse/onebox/blob/a45bfa115c9656d63240492f44b13a8f75a51785/lib/onebox/engine/whitelisted_generic_onebox.rb#L171-L173>

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [15 Agosto 2017, 3:20pm UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/20 "2017-08-15T15:20:36Z")

</div>

Optimized via:

[https://github.com/discourse/discourse/commit/b3540992523a0356b6e110c6760ef2e05707957e](https://github.com/discourse/discourse/commit/b3540992523a0356b6e110c6760ef2e05707957e)

and

[https://github.com/discourse/onebox/commit/e0103d3b6b31e850f3ae65b38bb7d1736b373c91](https://github.com/discourse/onebox/commit/e0103d3b6b31e850f3ae65b38bb7d1736b373c91)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [17 Agosto 2017, 8:05am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/21 "2017-08-17T08:05:53Z")

</div>

Okay, changes are deployed.

Demo:

> **[What is a onebox?](https://try.discourse.org/t/what-is-a-onebox/276/8)**
>
> The name “onebox” comes from Google: On top of the organic results (and sometimes at the bottom), Google shows OneBox results for queries that can be answered instantly or when a direct link can be offered. There are several kinds of OneBox...

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [17 Agosto 2017, 8:05am UTC](https://meta.discourse.org/t/incorrect-or-failing-oneboxes-for-links-to-other-discourse-instances/67351/22 "2017-08-17T08:05:55Z")

</div>


