Memory 019eae8c
Memory ID (Session ID): 019eae8c-759e-7000-92c7-6bb717bd90a2
Last Updated: 2026-06-10 01:46:50
Fact Summary
- Dependency Injection with Pydantic V2: To prevent DI containers from receiving complex instances instead of primitive config dicts, enforce
mode='json'during config dumps:container.from_dict(config.model_dump(mode='json')). Eliminate legacy_orig_from_pydanticshims. - Pydantic V2 Nested Root List Validation: When migrating/handling legacy dictionary payloads like
{"root": [...]}for lists, define the model asRootModel[list[AnySegment]]and use@model_validator(mode='before')to seamlessly parse the legacy structure. - Pytest/OpenTelemetry Shutdown Crashes: To prevent
ConsoleSpanExporterstdout flush crashes during Pytest teardown, conditionally disable the flush by checking the environment:if os.environ.get('PYTEST_CURRENT_TEST') is None:. - Async Mocking: Always use
AsyncMock(notMagicMock) for awaited dependencies to preventTypeError: object MagicMock can't be used in 'await' expression. - PlayAI/httpx testing: When testing
httpxclients with retry mechanisms, ensure mock assertions correctly account for thetimeoutparameter and handle potential retry jitter inmock_sleep.
Reference Session
- Associated Chat Session: 019eae8c-759e-7000-92c7-6bb717bd90a2