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_pydantic shims.
  • Pydantic V2 Nested Root List Validation: When migrating/handling legacy dictionary payloads like {"root": [...]} for lists, define the model as RootModel[list[AnySegment]] and use @model_validator(mode='before') to seamlessly parse the legacy structure.
  • Pytest/OpenTelemetry Shutdown Crashes: To prevent ConsoleSpanExporter stdout 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 (not MagicMock) for awaited dependencies to prevent TypeError: object MagicMock can't be used in 'await' expression.
  • PlayAI/httpx testing: When testing httpx clients with retry mechanisms, ensure mock assertions correctly account for the timeout parameter and handle potential retry jitter in mock_sleep.

Reference Session