# Topic\_link table contains wrong urls when using s3

**URL:** https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729
**Category:** Bug
**Created:** [February 7, 2021, 4:29pm UTC](https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729 "2021-02-07T16:29:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![caiiiycuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/caiiiycuk/32/201937_2.png) [@caiiiycuk](https://meta.discourse.org/u/caiiiycuk)
#### Post date: [February 7, 2021, 4:29pm UTC](https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729/1 "2021-02-07T16:29:00Z")

</div>

Hi. I faced problem that external link clicks not counted for url that contains uploaded files hosted on s3 + cdn. Look this topic to understand the problem:

[https://talks.dos.zone/t/collections/44653](https://talks.dos.zone/t/collections/44653)

Open a “Racing” category, you will see something like this:

 ![изображение](https://global.discourse-cdn.com/meta/original/3X/0/0/00ca3a30de9a303c0d80cf6d2da058ef9cf76bd7.png)

Test Drive never account a click on it. It’s because `topic_link` table does not contains record of it. All the links on this page use the same pattern: `https://dos.zone/rep/my/<encoded-url-to-file>`

All links that works correctly are on files uploaded manually. But, links that not counted uploaded with discourse. E.g.:  
`https://doszone-uploads.s3.dualstack.eu-central-1.amazonaws.com/custom/dos/death-rally.jsdos` - COUNTING,  
`https://doszone-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/2X/a/abcf902327ce1cf6fe7b3e8c809d638984377d7c.jsdos` - NOT COUNTING.

I dumped the `topic_link` table for this topic [topic\_link.csv](https://meta.discourse.org/uploads/short-url/2RLNz6xq6cvIJhR0flvMtwF86kZ.csv) (6.9 КБ)

If you look in it, all not counting links stored as `https://cdn.dos.zone/<path-to-file>` instead of correct `https://dos.zone/rep/my/<url-to-file>`. Counting links are stored correctly.

I tried to find why this happens but no luck, `topic_link.rb/extract_from` do nothing with cdn 🤔

---

<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: [February 8, 2021, 1:50am UTC](https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729/2 "2021-02-08T01:50:04Z")

</div>

This seems like something we should clean up. Probably our CDN substitution happens after the extraction.

@vinothkannans can you investigate and see if you can repro here as well?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [February 26, 2021, 4:21am UTC](https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729/4 "2021-02-26T04:21:05Z")

</div>

I’m unable to reproduce this issue yet. Anyway, it’s still in my list 📝

---

<div class="post-metadata">

### Author: ![caiiiycuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/caiiiycuk/32/201937_2.png) [@caiiiycuk](https://meta.discourse.org/u/caiiiycuk)
#### Post date: [February 26, 2021, 4:32am UTC](https://meta.discourse.org/t/topic-link-table-contains-wrong-urls-when-using-s3/178729/5 "2021-02-26T04:32:37Z")

</div>

Can I help you somehow?
