Prevent silent data corruption in conversation state - #5
Conversation
There was a problem hiding this comment.
Verified the validation against every call site of the touched methods. Live message appends come from voice/xai_bridge.py:150-158, which already guards with if text:, and store.create is only called from voice/twilio_webhook.py:94 where call_sid is explicitly rejected when "unknown" and caller is coerced via _sanitize(...) or "unknown" — so no existing path can newly raise. agent/brain.py's respond/generate_greeting are the only other callers and have no production callers today (only summarize_call is wired into the webhook, and it doesn't append messages), so the stricter behavior on an empty LLM reply is dormant and matches the PR's stated intent. Change is single-file, scoped to the described fix, with no security or error-swallowing concerns; the duplicated checks in create and __post_init__ are redundant but harmless.
What
Add validation and error handling for None/empty values in CallSession initialization and message storage methods.
Why
Prevents silent data corruption when invalid data is passed to conversation state, catching errors early with clear messages.