pinecone-io / pinecone-ts-client

The official TypeScript/Node client for the Pinecone vector database
https://www.pinecone.io
Apache License 2.0
166 stars 36 forks source link

[Bug] PineconeNotFoundError when there are 2 connections to pinecone #220

Closed bitterspeed closed 1 month ago

bitterspeed commented 1 month ago

Is this a new bug?

Current Behavior

If you run the code below to describeIndexStats in either order, the first call always works but the second call results in a not found error.

const clientOld = new Pinecone({
    apiKey: process.env['PINECONE_ELECTRON_API_KEY'] || '',
  });
  const pineconeIndexOld = clientOld.Index(
    process.env['PINECONE_ELECTRON_INDEX'] || ''
  );
  const clientNew = new Pinecone({
    apiKey: process.env['PINECONE_NEW_API_KEY'] || '',
  });
  const pineconeIndexNew = clientNew.Index(
    process.env['PINECONE_NEW_INDEX'] || ''
  );

  console.log(await pineconeIndexOld.describeIndexStats());
  console.log(await pineconeIndexNew.describeIndexStats());

PineconeNotFoundError: A call to https://api.pinecone.io/indexes/assist-law-electron returned HTTP status 404.
    at mapHttpStatusError (/Users/goodspeed/Documents/GitHub/socrates/node_modules/@pinecone-database/pinecone/src/errors/http.ts:154:14)
    at /Users/goodspeed/Documents/GitHub/socrates/node_modules/@pinecone-database/pinecone/src/errors/handling.ts:23:30
    at step (/Users/goodspeed/Documents/GitHub/socrates/node_modules/@pinecone-database/pinecone/dist/errors/handling.js:33:23)
    at Object.next (/Users/goodspeed/Documents/GitHub/socrates/node_modules/@pinecone-database/pinecone/dist/errors/handling.js:14:53)
    at fulfilled (/Users/goodspeed/Documents/GitHub/socrates/node_modules/@pinecone-database/pinecone/dist/errors/handling.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: undefined
}

Expected Behavior

I should be able to connect to 2 different pinecone instances

Steps To Reproduce

Run the code above

Relevant log output

No response

Environment

- **OS**: Mac Os
- **Language version**: Node 18.19.1
- **Pinecone client version**: 2.2.0

Additional Context

No response

mcpaddy commented 1 month ago

Thank you for bringing this to our attention. I can confirm we have reproduced the issue.

I also have a workaround if you call describeIndexit will work.

#!/usr/bin/node
import { Pinecone } from '@pinecone-database/pinecone';

const pcOne = new Pinecone({ apiKey: 'XXXX' });
const test = pcOne.Index('test');

const pcTwo = new Pinecone({ apiKey: 'XXXX' });
const test2 = pcTwo.Index('test2');

console.log(await pcTwo.describeIndex('test2'));
console.log(await test2.describeIndexStats());

console.log(await pcOne.describeIndex('test'));
console.log(await test.describeIndexStats());
austin-denoble commented 1 month ago

Thanks again for reporting, and thank you @mcpaddy for the workaround which was helpful for debugging. 🙂

I have a fix up here that I'd like to get merged and released quickly: https://github.com/pinecone-io/pinecone-ts-client/pull/224

austin-denoble commented 1 month ago

Release v2.2.2 includes a fix for this issue. Thanks again for contributing!

https://github.com/pinecone-io/pinecone-ts-client/releases/tag/v2.2.2