Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import with empty array fails #188

Open
davideaimar opened this issue Dec 18, 2023 · 0 comments
Open

Import with empty array fails #188

davideaimar opened this issue Dec 18, 2023 · 0 comments

Comments

@davideaimar
Copy link

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

@davideaimar davideaimar changed the title Import with empty array fail Import with empty array fails Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant