getByUID gives wrong document?

Hi there,
I have a really strange issue.
I queried our repo for a document by the doc's UID but the response object is different.
Here is an example:

api = PrismicService.init_api('repo')
=> #<Prismic::API:0x007ff33a06cd10 @json={"refs"=>[{"id"=>"master", "ref"=>"...", "label"=>"Master"......
doc = api.getByUID("content_type", "d40051", ref: api.master_ref.ref)
=> #<Prismic::Document:0x007ff33a0140e8 @id="...", @uid="d335161", @type="content_type" ......

So I can't understand why I get the doc with UID "d335161" when I requested the UID "d40051"?
Could you help me please?

Hi Zoltan,

This sounds like a duplicate UID issue, maybe this UID “d40051” had been previously used by the doc (UID “d335161”) and that’s why it’s appearing now.

This article can show you how to clear the UID from this document.

I can also help you check this if you can’t verify this is in the API browser, you can send me your repo url in a private message for that.

Thanks.

Hi Phil,
Thank you for your reply.
So you are saying it is normal to search for a UID and get another doc? And if I want another working method then I need to duplicate and delete each doc separately? Manually? One by one?
We have almost 3k docs in that repo, we imported them by the offered 200/zip batches. So I think you should offer a better solution for this issue.
Thanks.

No, I wouldn’t ask you to check 3000 documents, I’m only suggesting that for this document the issue might be that it has an older UID in it’s history.

We implemented the UID so old links aren’t broken when UID’s change, this protects users SEO from being negatively affected.

Again I’m happy to help you investigate this to see if this is actually the issue. Can you send me your repository URL in a private message and we can check this together?

Thanks.

This issue has been closed due to inactivity.