Item Key uniqueness and reuse after deletion

73 views
Skip to first unread message

williaml...@gmail.com

unread,
Oct 30, 2025, 9:58:38 AMOct 30
to zotero-dev
Hi all,

I have a question about how item keys are minted and managed, and more specifically what 'happens' to a key after the item it identifies is deleted? Essentially, I want to know whether there is a possibility that the deleted key could be recycled for a new item? Obviously the chances of a key collision would be minuscule even if a key can be reused after deletion, but it would be helpful to know if there is still that chance.

For some context on this question, our project uses the item keys, since they are unique within a group library, to mint URIs (appending them to the project's URI base, e.g. http://syriaca.org/cbss/25V6MWRL from https://www.zotero.org/groups/4861694/items/25V6MWRL). At present, to handle duplicates and other records that need to be deprecated, we maintain a list of URI redirects, and we tag deprecated records in Zotero rather than deleting them (e.g., https://www.zotero.org/groups/4861694/a_comprehensive_bibliography_on_syriac_studies/tags/_deprecated/library). So, for example, http://syriaca.org/cbss/BZURMQCN redirects to  http://syriaca.org/cbss/QKWA4HPW. The reason for the above question is that we do not want to delete deprecated records from Zotero if there's a chance that the item key will be reused in a new record, because the URI redirects would incorrectly flag the new item's URI as deprecated (not to mention that the same URI would then be identifying two distinct entities...).

It's no real trouble to continue our practice of retaining and tagging deprecated records, but we'd prefer the cleaner solution of deleting them from the library as long as we can be sure it won't cause issues down the line.

Grateful for any insights!
Best,

Will

Dan Stillman

unread,
Nov 10, 2025, 1:32:16 PMNov 10
to zoter...@googlegroups.com
On 10/30/25 9:58 AM, williaml...@gmail.com wrote:
> I have a question about how item keys are minted and managed, and more
> specifically what 'happens' to a key after the item it identifies is
> deleted? Essentially, I want to know whether there is a possibility
> that the deleted key could be recycled for a new item? Obviously the
> chances of a key collision would be minuscule even if a key can be
> reused after deletion, but it would be helpful to know if there is
> still that chance.

Yes, there's no guarantee that an object key won't reused in the future.

Emiliano Heyns

unread,
Nov 12, 2025, 4:06:32 AMNov 12
to zotero-dev
Is there even a 100% guarantee that object keys are unique even in the present? Theoretically, two clients synced to the same group can generate the same key, right? Very low probability I take it, but not impossible.

Dan Stillman

unread,
Nov 12, 2025, 3:41:41 PMNov 12
to zoter...@googlegroups.com
On 11/12/25 4:06 AM, 'Emiliano Heyns' via zotero-dev wrote:
> Is there even a 100% guarantee that object keys are unique even in the
> present? Theoretically, two clients synced to the same group can
> generate the same key, right? Very low probability I take it, but not
> impossible.

If the objects are synced, they're unique by definition, since there
can't be more than one object in an online library with a given key.
Personal vs. group doesn't make a difference.

When creating an item locally, we don't currently test whether a key
exists in the local database before trying to create the object. If it
does, the write will just fail and work again on the next attempt. (We
haven't done the math in a while, but we don't have any reason to think
this actually happens, or has happened more than a few times in Zotero's
existence.)

So if client A creates 'AAAAAAAA' and uploads it, any other client that
syncs that change (or client A itself) would just hit the above error if
it then tried to create an object with the same key.

If client A and client B both create 'AAAAAAAA' at the exact same time,
or while offline, 1) they're extraordinarily unlucky and 2) one of them
would get a conflict resolution window or some other weird error. This
wouldn't be great, but the odds of this happening are very, very low.

Emiliano Heyns

unread,
Nov 12, 2025, 4:20:50 PMNov 12
to zotero-dev
On Wednesday, November 12, 2025 at 9:41:41 PM UTC+1 Dan Stillman wrote:
On 11/12/25 4:06 AM, 'Emiliano Heyns' via zotero-dev wrote:
> Is there even a 100% guarantee that object keys are unique even in the
> present? Theoretically, two clients synced to the same group can
> generate the same key, right? Very low probability I take it, but not
> impossible.

If client A and client B both create 'AAAAAAAA' at the exact same time,
or while offline, 1) they're extraordinarily unlucky and 2) one of them
would get a conflict resolution window or some other weird error. This
wouldn't be great, but the odds of this happening are very, very low.

That's what I said, no? Very low probability. Just not zero. 

williaml...@gmail.com

unread,
Nov 18, 2025, 10:05:27 AM (10 days ago) Nov 18
to zotero-dev
Thanks all! It's good to have confirmation that there is a possibility for key reuse after deletion. As for the case where two clients could potentially generate the same key while offline, that is also good to know. Fortunately, with few enough contributors at present and an editorial workflow that relies primarily on the web library and API, this shouldn't be a problem since key collisions from two clients would be resolved (one way or another) prior to minting our project-specific URI and publishing the records to our web app.
Reply all
Reply to author
Forward
0 new messages