langchain-ai
langchain
BlogDocsChangelog

fix(core): Resolve 'FieldInfo is not JSON serializable' error in Pydantic v2

#33932
Comparing
jitokim:fix/pydantic-fieldinfo-serialization
(
bfedad2
) with
master
(
3dfea96
)
CodSpeed Performance Gauge
-3%
Untouched
13
Skipped
21

Benchmarks

Skipped (21)

Passed

test_import_time[LangChainTracer]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
0%
438.3 ms437.5 ms
test_async_callbacks_in_sync
libs/core/tests/benchmarks/test_async_callbacks.py
CodSpeed Performance Gauge
0%
24.4 ms24.5 ms
test_import_time[Document]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-2%
186.9 ms190.3 ms
test_import_time[InMemoryRateLimiter]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-3%
175.1 ms180.5 ms
test_import_time[HumanMessage]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-3%
265.4 ms274.6 ms
test_import_time[RunnableLambda]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-4%
477.3 ms495 ms
test_import_time[tool]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-4%
520.6 ms540 ms
test_import_time[InMemoryVectorStore]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-4%
605.4 ms630.1 ms
test_import_time[PydanticOutputParser]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-4%
522.5 ms543.9 ms
test_import_time[CallbackManager]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-4%
452.8 ms472 ms
test_import_time[Runnable]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-5%
481.8 ms507.8 ms
test_import_time[BaseChatModel]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-5%
524.1 ms554.3 ms
test_import_time[ChatPromptTemplate]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
-6%
590.7 ms630.5 ms

Commits

Click on a commit to change the comparison range
Base
master
3dfea96
-3.41%
fix(core): Prevent 'FieldInfo' is not JSON serializable error in Pydantic v2 Fixes TypeError when generating JSON schemas: "Object of type 'FieldInfo' is not JSON serializable". This occurs when model_json_schema() includes internal Pydantic metadata in the output. Solution: Add mode='serialization' parameter to model_json_schema() to ensure only JSON-serializable data structures are generated. Changes: - Modified _convert_pydantic_to_openai_function() to pass mode='serialization' - Added test_pydantic_fieldinfo_serialization() to verify correct behavior - Resolves nested Pydantic v2 model conversion issues Impact: - Fixes schema generation for nested Pydantic v2 models - No breaking changes (Pydantic v1 code path unchanged) - Previously failing test_convert_to_openai_function_nested_v2 now passes Signed-off-by: jitokim <pigberger70@gmail.com>
bfedad2
9 hours ago
by jitokim
© 2025 CodSpeed Technology
Home Terms Privacy Docs