pinecone-ts-client: [Bug] v1 Index.query throwing TypeError: Cannot read properties of undefined (reading 'text') during migration

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I’m migrating to v1 as described in https://github.com/pinecone-io/pinecone-ts-client/blob/main/v1-migration.md#query

I can upsert after migrating just fine, but I can’t query. My code is as follows:

    const namespace = ""
    const topK = 10
    const queryRequest = {
      vector: embeddings,
      topK,
      includeMetadata: true,
      includeValues: true,
    } as QueryByVectorValues;
    try {
      // Query the index with the defined request
      const ns = index.namespace(namespace);
      const queryResult = await ns.query(queryRequest);
      return queryResult.matches || [];
    } catch (e) {
      console.error("Error querying embeddings: ", e, (e as Error).stack);
      throw new Error(`Error querying embeddings: ${e}`);
    }

I have verified that there are actually embeddings (RecordValues).

The stack trace is a bit unhelpful:

TypeError: Cannot read properties of undefined (reading 'text')
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:136:40)
    at step (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:107:23)
    at Object.eval [as next] (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:48:20)
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:26:71)
    at new Promise (<anonymous>)
    at __awaiter (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:8:12)
    at extractMessage (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/utils.js:129:12)
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:178:76)
    at step (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:107:23)
    at Object.eval [as next] (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:48:20)
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:26:71)
    at new Promise (<anonymous>)
    at __awaiter (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:8:12)
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:171:36)
    at eval (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:151:25)
    at step (webpack-internal:///(rsc)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:107:23)

Any ideas?

Expected Behavior

No error to be thrown by ns.query, or, a helpful error message or stack trace.

Steps To Reproduce

See current behavior code.

Relevant log output

No response

Environment

- **OS**: Mac OS 13.5.2 (22G91)
- **Language version**: TypeScript, Nextjs 13
- **Pinecone client version**: 1.0.1

Additional Context

No response

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Comments: 16

Commits related to this issue

Most upvoted comments

I just shipped a v1.1.1 release that I don’t think will completely fix the problem but will hopefully result in a more useful error message than Cannot read properties of undefined (reading 'text')

If anyone experiencing this problem can share full details about your environment and dependencies (ideally a minimum reproduction case), that would be very helpful. So far I have not been able to reproduce the issue in our sample projects and integration tests.

Specifically it would help me to know:

  • Where are you running this when you see the error? On local, in Vercel edge runtime, or elsewhere (please specify: AWS lambda, etc)?
  • What dependencies does your project have in project.json?

I appreciate everyone’s patience as we work through this.

@jhamon Any update/thoughts on this? Not being able to use Vercel is a critical hit

I think I’ve solved this issue in the v1.1.0 release. Please upgrade and let us know if you’re still having a problem with this.

        const url = `${process.env.PINECONE_HOST!}/query`;

        const res = await fetch(url, {
            method: "POST",
            headers: {
                accept: "application/json",
                "Content-Type": "application/json",
                "Api-Key": process.env.PINECONE_API_KEY || "unknown",
            },
            body: JSON.stringify({
                includeValues: false,
                includeMetadata: true,
                topK: <topK>,
                vector: embeddings,
                namespace: <namespace>,
            }),
        });
        const resJson = await res.json() as QueryResponse<RecordMetadata>;

This worked for me.