Skip to content

Commit 22b25d6

Browse files
fix: use default_factory for mutable field defaults in ServerCallContext (a2aproject#744)
## summary - replace `default={}` and `default=UnauthenticatedUser()` with `default_factory=dict` and `default_factory=UnauthenticatedUser` in `ServerCallContext` to prevent shared mutable default instances across all instances.
1 parent a236d4d commit 22b25d6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/a2a/server/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ServerCallContext(BaseModel):
1919

2020
model_config = ConfigDict(arbitrary_types_allowed=True)
2121

22-
state: State = Field(default={})
23-
user: User = Field(default=UnauthenticatedUser())
22+
state: State = Field(default_factory=dict)
23+
user: User = Field(default_factory=UnauthenticatedUser)
2424
requested_extensions: set[str] = Field(default_factory=set)
2525
activated_extensions: set[str] = Field(default_factory=set)

0 commit comments

Comments
 (0)