ValidationError: 1 validation error for Document metadata Input should be a valid dictionary #44

Open
opened 2026-02-16 05:16:16 -05:00 by yindo · 1 comment
Owner

Originally created by @arthberman on GitHub (Sep 18, 2024).

Since LangChain 0.3 and within LangGraph Studio container, have the following error :
ValidationError: 1 validation error for Document metadata Input should be a valid dictionary [type=dict_type, input_value=Fragment(buf=b'{"name": "...name"}'), input_type=Fragment] For further information visit https://errors.pydantic.dev/2.9/v/dict_type
When running the following query :

results = self.vector_store.similarity_search(
            query=name,
            k=1,
            filter={"id": {"$eq": id}, "name": {"$eq": name}},
)

It happens when running vector_store.similarity_search query with metadata filters.
Seems to be linked to switch to Pydantic V2?

Originally created by @arthberman on GitHub (Sep 18, 2024). Since LangChain 0.3 and within LangGraph Studio container, have the following error : `ValidationError: 1 validation error for Document metadata Input should be a valid dictionary [type=dict_type, input_value=Fragment(buf=b'{"name": "...name"}'), input_type=Fragment] For further information visit https://errors.pydantic.dev/2.9/v/dict_type ` When running the following query : ``` results = self.vector_store.similarity_search( query=name, k=1, filter={"id": {"$eq": id}, "name": {"$eq": name}}, ) ``` It happens when running vector_store.similarity_search query with metadata filters. Seems to be linked to switch to Pydantic V2?
Author
Owner

@arthberman commented on GitHub (Sep 18, 2024):

pyproject.toml

`[project]
name = ""
version = "0.0.1"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"python-dotenv>=1.0.1",
"langchain>=0.3.0",
"langchain-community>=0.3.0",
"langchainhub>=0.1.21",
"langchain-anthropic>=0.2.1",
"langchain-groq>=0.2.0",
"langchain-core>=0.3.1",
"langgraph>=0.2.22",
"langchain-openai>=0.2.0",
"pydantic>=2.9.2",
"temporalio>=1.7.1",
"toml>=0.10.2",
"packaging>=24.1",
"ipykernel>=6.29.5",
"langgraph-checkpoint-postgres>=1.0.7",
"langgraph-sdk>=0.1.30",
"langchain-postgres>=0.0.12",
"psycopg2-binary>=2.9.9",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = ["ipykernel>=6.29.5"]

[tool.hatch.build.targets.wheel]
packages = ["src/app", "src/parser", "src/utils"]
`

@arthberman commented on GitHub (Sep 18, 2024): pyproject.toml `[project] name = "" version = "0.0.1" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "python-dotenv>=1.0.1", "langchain>=0.3.0", "langchain-community>=0.3.0", "langchainhub>=0.1.21", "langchain-anthropic>=0.2.1", "langchain-groq>=0.2.0", "langchain-core>=0.3.1", "langgraph>=0.2.22", "langchain-openai>=0.2.0", "pydantic>=2.9.2", "temporalio>=1.7.1", "toml>=0.10.2", "packaging>=24.1", "ipykernel>=6.29.5", "langgraph-checkpoint-postgres>=1.0.7", "langgraph-sdk>=0.1.30", "langchain-postgres>=0.0.12", "psycopg2-binary>=2.9.9", ] [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [tool.uv] dev-dependencies = ["ipykernel>=6.29.5"] [tool.hatch.build.targets.wheel] packages = ["src/app", "src/parser", "src/utils"] `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#44