Skip to content

properly handle explicit metadata columns in PostgresVectorStore for google cloud sql #8334

@Sriram-52

Description

@Sriram-52

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

libs/langchain-google-cloud-sql-pg/src/vectorstore.ts:368

class PostgresVectorStore extends vectorstores_1.VectorStore {
             delete allColumns[contentColumn];
             delete allColumns[embeddingColumn];
             allMetadataColumns = Object.keys(allColumns);
+        } else {
+            for (const column of metadataColumns) {
+                if (Object.prototype.hasOwnProperty.call(allColumns, column)) {
+                    allMetadataColumns.push(column);
+                }
+            }
         }
         return new PostgresVectorStore(embeddings, {
             engine,

Error Message and Stack Trace (if applicable)

No response

Description

When using the PostgresVectorStore with explicitly specified metadata columns, the system was not properly handling these columns. The code was only processing metadata columns when they weren't explicitly provided, which could lead to missing or incomplete metadata in the vector store operations.

System Info

langchain@0.3.27 | MIT | deps: 12 | versions: 322
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/

keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores

dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.3.27.tgz
.shasum: e0ed686765dba3809f90a214110bee445cf240a8
.integrity: sha512-XfOuXetMSpkS11Mt6YJkDmvuSGTMPUsks5DJz4RCZ3y2dcbLkOe5kecjx2SWVJYqQIqcMMwsjsve3/ZjnRe7rQ==
.unpackedSize: 2.9 MB

dependencies:
@langchain/openai: >=0.1.0 <0.6.0
@langchain/textsplitters: >=0.0.0 <0.2.0
js-tiktoken: ^1.0.12
js-yaml: ^4.1.0
jsonpointer: ^5.0.1
langsmith: ^0.3.29
openapi-types: ^12.1.3
p-retry: 4
uuid: ^10.0.0
yaml: ^2.2.1
zod-to-json-schema: ^3.22.3
zod: ^3.22.4

maintainers:

dist-tags:
latest: 0.3.27
next: 0.3.2-rc.0
tag-for-publishing-older-releases: 0.2.20

published 2 weeks ago by benjamincburns benjamin.c.burns@gmail.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto:bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions