Problem with creating Topic with external_id


  1. Created a Topic (using rest api) with “external_id” field
  2. Deleted that Topic, I assume that Topic will be there in the Database but it will be hidden from users
  3. Tried to create the Same Topic with same “external_id”, I get “External has already been taken”

If the Topic is deleted from users point of view, then the user should be able to create a new Topic with the same data, but why it is not happening there seems to be no way to use the same “external_id”. Looks like a bug.

2022/10/12 12:33:32 resp: &{Status:404 Not Found StatusCode:404 Proto:HTTP/2.0 ProtoMajor:2 ProtoMinor:0 Header:map[Content-Type:[application/json; charset=utf-8] Date:[Wed, 12 Oct 2022 10:33:32 GMT] Referrer-Policy:[strict-origin-when-cross-origin] Server:[nginx] Vary:[Accept-Encoding] X-Content-Type-Options:[nosniff] X-Discourse-Route:[topics/show_by_external_id] X-Discourse-Username:[mohan43u] X-Download-Options:[noopen] X-Frame-Options:[SAMEORIGIN] X-Permitted-Cross-Domain-Policies:[none] X-Request-Id:[26b86048-937c-451c-ac0c-b23dbcd3c8ca] X-Runtime:[0.013603] X-Xss-Protection:[0]] Body:0xc000183bc0 ContentLength:-1 TransferEncoding:[] Close:false Uncompressed:true Trailer:map[] Request:0xc00030a800 TLS:0xc0000d22c0}
2022/10/12 12:33:32 req: &{Method:GET URL: Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Api-Key:[] Api-Username:[mohan43u]] Body:<nil> GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr: RequestURI: TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc0000260b8}
2022/10/12 12:33:32 {"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}
2022/10/12 12:33:32 uploading
2022/10/12 12:33:32 {"title":"[Youtube] ஆண்ட்ராய்டுக்கான கட்டற்ற மென்பொருள் | FOSS for Android | F-Droid | Tamil","raw":"\nஇந்த காணொளியில் F-Droid எவ்வாறு பயன்படுத்துவது? அதன் பயன் என்ன ? - என்பதை காண்போம்.\n\nகாணொளி வழங்கியவர்: \nமணிமாறன், விழுப்புரம் கட்டற்ற மென்பொருள் குழுமம்\n\nF-Droid:\n\n#fdroid #fossforandroid #tamil #android #vglug","category":3,"external_id":"7N69MKNwQAs"}

2022/10/12 12:33:33 failed to create Topic:
2022/10/12 12:33:33 err: <nil>
2022/10/12 12:33:33 resp: &{Status:422 Unprocessable Entity StatusCode:422 Proto:HTTP/2.0 ProtoMajor:2 ProtoMinor:0 Header:map[Cache-Control:[no-cache, no-store] Content-Type:[application/json; charset=utf-8] Date:[Wed, 12 Oct 2022 10:33:33 GMT] Referrer-Policy:[strict-origin-when-cross-origin] Server:[nginx] X-Content-Type-Options:[nosniff] X-Discourse-Route:[posts/create] X-Discourse-Username:[mohan43u] X-Download-Options:[noopen] X-Frame-Options:[SAMEORIGIN] X-Permitted-Cross-Domain-Policies:[none] X-Request-Id:[217f7585-269a-48b3-ac5e-215e02e76bdb] X-Runtime:[0.060606] X-Xss-Protection:[0]] Body:{cs:0xc00032c180} ContentLength:-1 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc000352100 TLS:0xc0000d22c0}
2022/10/12 12:33:33 req: &{Method:POST URL: Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Api-Key:[] Api-Username:[mohan43u] Content-Type:[application/json]] Body:0xc0005b0228 GetBody:0x6b0e40 ContentLength:733 TransferEncoding:[] Close:false Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr: RequestURI: TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc0000260b8}
2022/10/12 12:33:33 {"action":"create_post","errors":["Title has already been used","External has already been taken"]}

What would happen if the first topic was undeleted?

1 Like

there is no way to undelete that first topic, I dont see any icon/button to do undelete.

Hi Mohan. :wave:

I think what @RGJ was referring to: this isn’t a bug, since Discourse uses a “soft delete” approach by default. The external_id would be used in that context, which is by design. :+1:


The icon for un-delete is this one:

And there is also the option in the topic wrench:

There is nothing like that

The point is that such a topic can be undeleted, and in that case there would be two topics with the same external ID. The externalID is supposed to be unique, across all topics, including deleted ones. As @maiki said, this is by design.

1 Like

can be undeleted? how? I too want to undelete that topic, my problem will go away. but there is no way to undelete that topic.

Either discourse should allow to use the external_id which is used on a deleted topic or it should have some way to undelete the deleted topic with that external_id. I see none of these two.

So obviously it a bug.

The posts above mine clearly indicate that topics can be undeleted. That you seem unable to undelete this specific topic to does not mean that this is a bug, it would be a matter of permissions or settings.

Are you administrator on the forum?

BTW Please stop classifying this as #bug.

1 Like

should I classify this as a bug?

No, you should not.

Please use safe mode and see if you can do this. If you cannot, please tell us in great detail what you do see instead. Screen captures will help.

Let me know if I’m trying wrong way


The undelete button is on the “deleted” topic. So you need to view it and undelete it from there.

You can not access the appropriate menu from the user delete posts list. You have to go to the topic itself to see the option in the menu:

@Mohan43u, does that answer your original question, about how the external_id is used? :slight_smile:

Yes, but @Mohan43u does have a point, there is no way to go there from the “deleted posts” list. So how do you get to that topic?

Also, ?status=deleted does not seem to work any more?

There is no way to go to that deleted topic apart from my profile page. It is not at all reachable from the categories.

/latest?status=deleted works for me on my test site?

Ahhh, I see now. The video definitely helped. :slight_smile: Yes, the topic title doesn’t currently appear on deleted topics from that view. This has been raised previously, but it may be worth another look. :+1:

Could you try [YourSite]/latest?status=deleted and seeing if you can access the topic from the topic list there instead?

And now I’ve found the other topic, there is also another tip to navigate to the deleted topic via your staff logs too, if that’s any help:

1 Like

Totally clean forum, tests-passed as of this morning. When I undelete the topic it does appear on latest again.

Good suggestion!!
But it would be really nice if the deleted post in the profile would allow navigation to it too.

1 Like

I think your one is hidden by the welcome topic banner CTA. Could you try hiding it in your console and seeing if the topic is behind it? (or edit the welcome topic to dismiss the banner :slight_smile:)

1 Like

You are right!

That is both brilliant (your response) and very sad (the reason) at the same time.

So now we have two reasons to recategorize this to #ux

1 Like

Thank you so much, I was able to recover that topic and my rest-api client is happy.