diff --git a/src/cloudflare/internal/vectorize-api.ts b/src/cloudflare/internal/vectorize-api.ts index 070c4b7e4d9..3943571d4a9 100644 --- a/src/cloudflare/internal/vectorize-api.ts +++ b/src/cloudflare/internal/vectorize-api.ts @@ -47,7 +47,7 @@ class VectorizeIndexImpl implements Vectorize { if (this.indexVersion === "v2") { if (!isVectorizeMetadataRetrievalLevel(options?.returnMetadata) ) { throw new Error( - `Invalid returnMetadata option. Expected: "none", "indexed" or "all"; got: ${options.returnMetadata}` + `Invalid returnMetadata option. Expected: "none", "indexed" or "all"; got: ${options?.returnMetadata}` ); } const res = await this._send(Operation.VECTOR_QUERY, `query`, { @@ -64,9 +64,9 @@ class VectorizeIndexImpl implements Vectorize { return await toJson(res); } else { - if (options && options.returnMetadata && typeof options.returnMetadata !== 'boolean') { + if (typeof options?.returnMetadata !== 'boolean') { throw new Error( - `Invalid returnMetadata option. Expected boolean; got: ${options.returnMetadata}` + `Invalid returnMetadata option. Expected boolean; got: ${options?.returnMetadata}` ); } const compat = {