Skip to content

Local Zotero: sub-collections always come back empty (stray quote in collectionSQL) #1137

Description

@nealrichardson

Bug

collectionSQL() in packages/editor-server/src/core/zotero/local/source.ts:594 has a stray single quote in the sub-collection branch:

const where = spec.parentKey.length > 0
  ? `AND collections.key = :k'`   // <-- trailing '
  : `AND libraries.libraryID = :k`;

The ' opens an unterminated string literal, so the query fails with a SQLite syntax error whenever spec.parentKey is non-empty, i.e. for any Zotero sub-collection read from the local database.

Impact

The error is caught in the collection reader (source.ts ~line 280: console.error(error); return collection;), so a sub-collection silently comes back with zero items. Users see the sub-collection in the citation UI with nothing in it, and nothing surfaces except a console log in the LSP output.

Top-level libraries are unaffected (they take the other branch).

Fix

Drop the quote: AND collections.key = :k. The sibling creatorsSQL() (~line 553) already has the correct form.

Testing

Worth adding a test that runs collectionSQL() for a spec with a non-empty parentKey against a fixture Zotero sqlite (or at least db.prepare()s the SQL), so a syntax error like this gets caught.

Found during the dependency-upgrade research.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions