-
Notifications
You must be signed in to change notification settings - Fork 13
Handle EOFError in RecordAdapter #203
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
Conversation
When stdin is empty, raise EOFError and log this as a warning. fixes #202
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #203 +/- ##
==========================================
+ Coverage 83.25% 83.32% +0.07%
==========================================
Files 35 35
Lines 3702 3707 +5
==========================================
+ Hits 3082 3089 +7
+ Misses 620 618 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 proper handling for empty input streams when reading from stdin. When stdin is empty, the code now raises an EOFError with a descriptive message and logs it as a warning instead of failing silently or with a confusing error.
Changes:
- Added EOFError detection and handling when peek_data is empty in RecordAdapter
- Improved exception handling in record_stream with dedicated EOFError catch block and finally block for cleanup
- Added comprehensive test coverage for empty stdin scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| flow/record/base.py | Raises EOFError when detecting empty input stream during adapter selection |
| flow/record/stream.py | Adds EOFError exception handling with warning log and improves resource cleanup with finally block |
| tests/record/test_adapter.py | Adds unit test verifying EOFError is raised for empty stdin |
| tests/tools/test_rdump.py | Adds integration tests for empty records file and empty stdin scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
It seems the test from https://github.com/fox-it/flow.record/pull/177/changes#diff-4d5cab263639439a90d5ce0d7d7c87b37f5305a00d45f3d9577bc76755c959adR101-R113 does not work with the current changes in this branch. |
Can you elaborate? we did not introduce any new flags in this PR. I ported the test that exits with an error in my last commit. Also the stderr does not say |
The flag is indeed now irrelevant. The tests fail with input such as The tests in #177 state that the exit code should be |
note that The test with |
Agreed. Thanks for elaborating. |
When stdin is empty, raise EOFError and log this as a warning.
fixes #202