@@ -628,12 +628,6 @@ def test_start_as_current_observation_types(self, langfuse_client, memory_export
628628 LangfuseOtelSpanAttributes .OBSERVATION_TYPE
629629 )
630630
631- # Debug: print all attributes for this span
632- print (
633- f"Span { expected_name } attributes: { list (span_data ['attributes' ].keys ())} "
634- )
635- print (f"Expected: { expected_otel_type } , Actual: { actual_type } " )
636-
637631 assert (
638632 actual_type == expected_otel_type
639633 ), f"Expected observation type { expected_otel_type } , got { actual_type } "
@@ -3036,3 +3030,33 @@ def test_different_seeds_produce_different_ids(self, langfuse_client):
30363030
30373031 # All observation IDs should be unique
30383032 assert len (set (observation_ids )) == len (seeds )
3033+
3034+ def test_langfuse_event_update_immutability (self , langfuse_client , memory_exporter , caplog ):
3035+ """Test that LangfuseEvent.update() logs a warning and does nothing."""
3036+ import logging
3037+
3038+ parent_span = langfuse_client .start_span (name = "parent-span" )
3039+
3040+ event = parent_span .start_observation (
3041+ name = "test-event" ,
3042+ as_type = "event" ,
3043+ input = {"original" : "input" },
3044+ )
3045+
3046+ # Try to update the event and capture warning logs
3047+ with caplog .at_level (logging .WARNING , logger = 'langfuse._client.span' ):
3048+ result = event .update (
3049+ name = "updated_name" ,
3050+ input = {"updated" : "input" },
3051+ output = {"updated" : "output" },
3052+ metadata = {"updated" : "metadata" }
3053+ )
3054+
3055+ # Verify warning was logged
3056+ assert "Attempted to update LangfuseEvent observation" in caplog .text
3057+ assert "Events are immutable and cannot be updated after creation" in caplog .text
3058+
3059+ # Verify the method returned self unchanged
3060+ assert result is event
3061+
3062+ parent_span .end ()
0 commit comments