From 0928d2346db59d4aa06678bd8b2181695dcfadb1 Mon Sep 17 00:00:00 2001 From: STHITAPRAJNAS Date: Fri, 27 Mar 2026 13:07:51 +0000 Subject: [PATCH] test(sessions): tighten v0 error_message truncation assertions per review - Replace <= with == in the truncation test: the guard is deterministic so the result should be exactly 255 chars, not merely at most 255 - Assert the concrete expected string ("x" * 241 + "...[truncated]") rather than importing private module symbols, reducing coupling to internal implementation details - Add test_from_event_with_none_error_message to cover the falsy branch of the truncation condition and document that None passes through unchanged --- .../sessions/test_v0_storage_event.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unittests/sessions/test_v0_storage_event.py b/tests/unittests/sessions/test_v0_storage_event.py index 3f542af8b4..9fbfbb09fb 100644 --- a/tests/unittests/sessions/test_v0_storage_event.py +++ b/tests/unittests/sessions/test_v0_storage_event.py @@ -125,3 +125,24 @@ def test_from_event_preserves_short_error_message(): storage_event = StorageEvent.from_event(session, event) assert storage_event.error_message == short_error + + +def test_from_event_with_none_error_message(): + session = Session( + app_name="app", + user_id="user", + id="session_id", + state={}, + events=[], + last_update_time=0.0, + ) + event = Event( + id="event_id", + invocation_id="inv_id", + author="agent", + timestamp=1.0, + ) + + storage_event = StorageEvent.from_event(session, event) + + assert storage_event.error_message is None