haystack-core-integrations
haystack-core-integrations copied to clipboard
bug(langfuse): test_create_new_span causes excessive RAM usage and hangs due to unspecced MagicMock
Describe the bug The issue is on line 537 where mock_raw_span = MagicMock() is created without a spec parameter. When this mock is passed through the tracer's handle() method, it triggers unbounded creation of child MagicMock objects because:
- Every attribute access (span.get_data(), span.raw_span(), etc.) creates new MagicMock instances
- MagicMock stores all calls and arguments in memory for assertion tracking
- Without a spec, there are no boundaries preventing infinite mock object creation
- The handle() method makes numerous such calls (lines 352-421 in tracer.py)
To Reproduce
cd integrations/langfuse
hatch run test:unit tests/test_tracer.py::TestLangfuseTracer::test_create_new_span -v
Describe your environment (please complete the following information):
- OS: Universal Dev Container
- Integration version: Commit 4ed293674e4f8b4698584e9e8da9e7ddcf5f7d2e