-
Notifications
You must be signed in to change notification settings - Fork 53
Add tests to verify forward compatibility for unknown session event types #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests to verify forward compatibility for unknown session event types #35
Conversation
…ython SDK Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
|
@copilot Don't suppress parsing errors. Those should always surface for visiblity. The only forward compatibility we want here is handling previously-unknown event types, which might already be covered in latest |
…ility Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com>
You're absolutely right. The original issue was already fixed in the base code - I've reverted the broad try-catch blocks that were suppressing all parsing errors. The generated code at lines 676-679 already handles unknown event types correctly without hiding real errors. Changes in commit 39d47dc:
The SDK now properly:
|
Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com>
|
@copilot Run the Python formatter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive unit tests to verify that the Python SDK's existing forward compatibility mechanism for session events works correctly. The generated code already includes proper handling for unknown event types by mapping them to SessionEventType.UNKNOWN, and this PR validates that behavior.
Changes:
- Added
test_event_forward_compatibility.pywith 4 test cases verifying enum recognition, unknown event handling, and error visibility - Tests confirm that malformed data raises appropriate errors and unknown event types map to UNKNOWN enum value
- No code changes required as forward compatibility was already implemented in the generated session_events.py
Comments suppressed due to low confidence (1)
python/test_event_forward_compatibility.py:14
- Missing import for dateutil.parser.ParserError. The from_datetime function in session_events.py uses dateutil.parser.parse() which raises ParserError for invalid timestamps. Add: from dateutil.parser import ParserError
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| # This should raise an error and NOT be silently suppressed | ||
| with pytest.raises((ValueError, TypeError)): |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected exceptions should include ParserError from dateutil.parser, as the from_datetime function uses dateutil.parser.parse() which raises ParserError for invalid timestamps, not just ValueError or TypeError. Consider adding: with pytest.raises((ValueError, TypeError, dateutil.parser.ParserError))
This issue also appears in the following locations of the same file:
- line 14
Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com>
Add tests to verify forward compatibility for unknown session event types
Summary
The original issue (
session.usage_infoValueError) was already fixed in the base code. The generatedsession_events.pyalready includesSESSION_USAGE_INFOin the enum and handles unknown event types by mapping them toSessionEventType.UNKNOWNfor forward compatibility.This PR adds tests to verify that the existing forward compatibility mechanism works correctly.
Changes
test_event_forward_compatibility.pyverifying:session.usage_infois recognized in the enumUNKNOWNenum value for forward compatibilityContext
The generated code in
session_events.py(lines 676-679) already contains proper error handling for unknown event types:This approach correctly handles unknown event types for forward compatibility while allowing real parsing errors (like malformed UUIDs or timestamps) to surface for debugging visibility.
Testing
✅ All 4 tests pass:
Code Review
✅ Addressed all feedback from @SteveSandersonMS
✅ Applied Python formatter (ruff format)
The tests confirm that the SDK already handles the reported issue gracefully without requiring code changes.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.