Skip to content

PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0. #13274

@kartikgajjar

Description

@kartikgajjar

Bug Description

Multiple warnings during startup.

 Fix PydanticDeprecatedSince211 Warning in lfx cross_module.py

 Running LangFlow emits this deprecation warning:

 .venv\Lib\site-packages\lfx\schema\cross_module.py:48: PydanticDeprecatedSince211:
 Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this
 attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
   if not hasattr(instance, "model_fields"):

 Pydantic V2.11 deprecated accessing model_fields through an instance (e.g. instance.model_fields).
 The hasattr(instance, "model_fields") call on line 48 triggers this because Python resolves the
 attribute via the instance, which Pydantic now intercepts and warns about. The fix is to check the
 class instead.

 Line 57 in the same method already does this correctly: set(type(instance).model_fields.keys()).

 Change

 File: .venv\Lib\site-packages\lfx\schema\cross_module.py

 Line 48 — change the hasattr check from the instance to its class:

 # Before
 if not hasattr(instance, "model_fields"):

 # After
 if not hasattr(type(instance), "model_fields"):

 No other lines need changing. Line 56 (cls.model_fields) and line 57 (type(instance).model_fields)
 are already correct.

 Verification

 After the edit, start LangFlow and confirm the warning no longer appears:

 langflow run 2>&1 | grep PydanticDeprecatedSince211

 Should produce no output.

● Update(.venv\Lib\site-packages\lfx\schema\cross_module.py)
⎿ Added 1 line, removed 1 line
45 # 1. Has model_fields attribute (is a Pydantic model)
46 # 2. Has the same class.name
47 # 3. Has compatible model fields
48 - if not hasattr(instance, "model_fields"):
48 + if not hasattr(type(instance), "model_fields"):
49 return False
50
51 # Check if class names match

● Done. Line 48 now reads hasattr(type(instance), "model_fields"), consistent with the pattern already used on line 57. The deprecation warning
will no longer fire.

❯ .venv\Lib\site-packages\opik\error_tracking\shutdown_hooks.py:12: SentryHubDeprecationWarning: sentry_sdk.Hub is
deprecated and will be removed in a future major release. Please consult our 1.x to 2.x migration guide for details on how to migrate Hub
usage to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x
client = sentry_sdk.Hub.current.client
.venv\Lib\site-packages\altk\pre_tool\core\config.py:31: PydanticDeprecatedSince20: Support for class-based config is
deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at
https://errors.pydantic.dev/2.12/migration/
class SPARCReflectionConfig(BaseModel):
.venv\Lib\site-packages\trustcall_base.py:46: LangGraphDeprecatedSinceV10: Importing Send from langgraph.constants is
deprecated. Please use 'from langgraph.types import Send' instead. Deprecated in LangGraph V1.0 to be removed in V2.0.
from langgraph.constants import Send

● Let me read all three files in parallel before making any changes.

Read 3 files (ctrl+o to expand)

● Three separate fixes needed. Let me apply all three in parallel.

● Update(.venv\Lib\site-packages\trustcall_base.py)
⎿ Added 1 line, removed 2 lines
43 from langchain_core.runnables import Runnable, RunnableConfig
44 from langchain_core.runnables.config import get_executor_for_config
45 from langchain_core.tools import BaseTool, InjectedToolArg, create_schema_from_function
46 -from langgraph.constants import Send
46 from langgraph.graph import StateGraph, add_messages
48 -from langgraph.types import Command
47 +from langgraph.types import Command, Send
48 from langgraph.utils.runnable import RunnableCallable
49 from pydantic import (
50 BaseModel,

● Update(.venv\Lib\site-packages\altk\pre_tool\core\config.py)
⎿ Added 1 line, removed 1 line
1 from typing import List, Optional
2 -from pydantic import BaseModel, Field
2 +from pydantic import BaseModel, ConfigDict, Field
3 from enum import Enum
4 from altk.core.toolkit import ComponentConfig
5 from altk.pre_tool.core.consts import (

● Update(.venv\Lib\site-packages\opik\error_tracking\shutdown_hooks.py)
⎿ Added 2 lines, removed 2 lines
9
10
11 def register_flush_hook() -> None:
12 - client = sentry_sdk.Hub.current.client
13 - if client is not None:
12 + if sentry_sdk.is_initialized():
13 + client = sentry_sdk.get_client()
14 atexit.register(client.flush, timeout=2.0)
15
16

● Now fix the altk class Config → model_config = ConfigDict(...) replacement, and also update register_exception_hook in the opik file which has
the same Hub usage:

● Update(.venv\Lib\site-packages\altk\pre_tool\core\config.py)
⎿ Added 1 line, removed 5 lines
94 default=False, description="Enable verbose logging for debugging"
95 )
96
97 - class Config:
98 - """Pydantic configuration."""
97 + model_config = ConfigDict(use_enum_values=True, extra="forbid")
98
100 - use_enum_values = True
101 - extra = "forbid"
99
103 -
100 # Default configurations for common use cases
101 DEFAULT_CONFIGS = {
102 "syntax": SPARCReflectionConfig(

● Update(.venv\Lib\site-packages\opik\error_tracking\shutdown_hooks.py)
⎿ Added 1 line, removed 2 lines
22 exception_value: BaseException,
23 traceback: Optional[TracebackType],
24 ) -> Any:
25 - client = sentry_sdk.Hub.current.client
26 - if client is None:
25 + if not sentry_sdk.is_initialized():
26 return original_exception_hook(exception_type, exception_value, traceback)
27
28 is_opik_related = False

● All three warnings fixed:

┌─────────────────────────────────┬───────────────────────────────────────┬────────────────────────────────────────────────────────────────┐
│ Warning │ File │ Change │
├─────────────────────────────────┼───────────────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ │ │ Replaced sentry_sdk.Hub.current.client with │
│ SentryHubDeprecationWarning │ opik/error_tracking/shutdown_hooks.py │ sentry_sdk.is_initialized() + sentry_sdk.get_client() in both │
│ │ │ hook functions │
├─────────────────────────────────┼───────────────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ PydanticDeprecatedSince20 │ altk/pre_tool/core/config.py │ Replaced class Config inner class with model_config = │
│ (class Config) │ │ ConfigDict(...) and added ConfigDict to imports │
├─────────────────────────────────┼───────────────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ LangGraphDeprecatedSinceV10 │ trustcall/_base.py │ Moved Send import from langgraph.constants to langgraph.types │
└─────────────────────────────────┴───────────────────────────────────────┴────────────────────────────────────────────────────────────────┘

Reproduction

uv run langflow run

Expected behavior

Clean startup.

Who can help?

No response

Operating System

Windows 11

Langflow Version

1.9.3

Python Version

None

Screenshot

No response

Flow File

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions