Skip to content

Import with empty array fails #188

Open
@davideaimar

Description

@davideaimar

Description

Calling the import function with an empty array fails.

Steps to reproduce

Initialize a collection and try to call import with an empty array:

const documents = [];

return await tsClient
  .collections<T>('testcollection')
  .documents()
  .import(documents); // this fails

Expected Behavior

It doesn't fail.

Actual Behavior

It fails with this error:

/Users/<path-to-project>/node_modules/typesense/src/Typesense/Documents.ts:342
        .map((r) => JSON.parse(r)) as ImportResponse[];
         ^
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /Users/<path-to-project>/node_modules/typesense/src/Typesense/Documents.ts:342:26
    at Array.map (<anonymous>)
    at Documents.<anonymous> (/Users/<path-to-project>/node_modules/typesense/src/Typesense/Documents.ts:342:10)
    at step (/Users/<path-to-project>/node_modules/typesense/lib/Typesense/Documents.js:48:23)
    at Object.next (/Users/<path-to-project>/node_modules/typesense/lib/Typesense/Documents.js:29:53)
    at fulfilled (/Users/<path-to-project>/node_modules/typesense/lib/Typesense/Documents.js:20:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Metadata

Typesense Version: 0.25.1

OS: Run in Docker

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