Not a valid collection key upon syncing

report ID: 1369579449

I've attempted to organize my collections using this here:
https://github.com/pastorpflores/Zotero-AI-organizer

What it does is suggest names for new collections based on ones library, and then classify papers within those collections.

Things work as expected, expect they break the sync. Apart from sync, everything works just fine on local.

The error that appears upon sync is "not a valid collection key".
I looked through the Zotero source code and could not find any information suggesting what a valid collection key should look like.
Would anyone have any ideas how I could 1. either fix the sync or 2. generate valid collection keys that would not break the sync in the first place?

Thank you!
  • dstillman Zotero Team
    For problems with a plugin, you'll need to contact the plugin developer.
  • Thank you.
    This is not an actual plugin. It's an external tool that modifies the Zotero.sqlite directly.

    I was wondering if anyone knows where I can find what a "valid collection key" looks like, so I could try to fix the issue myself.

    I'll reach out to the developer as well.
  • External tools should never modify Zotero's database directly. Zotero supports plugins and a read-write web API for use cases like this. There's no practical way to verify that the modifications that that program is making to your database won't lead to corruption; you just shouldn't use it.
  • Hi, I'm the author of the tool that was mentioned here. I found this thread when I activated the Sync and faced the same error, lmao.

    I'm not a developer, just a researcher who wanted a way to organize my Zotero library with AI and built this with the tools and knowledge I had available.

    I understand this should be done properly as a plugin or using the Zotero Web API, but this was my best attempt at the time.

    For anyone who ran into the same sync issue, here is the fix I found:

    The problem was that the tool was generating collection keys using Python's `string.ascii_uppercase + string.digits`, which includes the characters `0`, `1`, `I`, and `O`. Looking at keys that were already successfully synced in my database, none of them contained those characters, so I replaced any key containing them with ones that didn't. This resolved the sync error.

    To fix an affected database:

    1. Close Zotero
    2. For each collection with `synced=0` and a key containing `0`, `1`, `I`, or `O`, generate a new key without those characters and update the `collections` table
    3. Delete the corresponding entries in `syncCache` and insert new ones with the corrected keys, making sure parent key references in the JSON are also updated
    4. Set `version` and `synced=1` on all previously unsynced collections so Zotero recognizes them as ready to sync

    I have updated the tool repository to use a character set that avoids those characters going forward.
  • dstillman Zotero Team
    @pastorpflores: We'd appreciate if you would take this tool down and replace the README with instructions for repairing the broken database. As we say, external tools should never modify the database directly. Simply fixing this problem is not sufficient. People should not be using a tool that modifies the database this way.
Sign In or Register to comment.