-
Couldn't load subscription status.
- Fork 4
FakeService: filter: Fix field-existance check #212
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
Signed-off-by: Mathias L. Baumann <[email protected]>
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 fixes a bug in the FakeService filter implementation where field existence was not properly checked before accessing optional protobuf fields. The fix replaces the walrus operator with explicit HasField() checks to correctly determine if optional fields are set.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/frequenz/client/dispatch/test/_service.py | Updates filter logic to use HasField() instead of walrus operator for checking protobuf field existence |
| tests/test_service.py | Adds comprehensive test coverage for start_time and end_time filtering functionality |
| RELEASE_NOTES.md | Documents the bug fix in release notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if dispatch.duration and ( | ||
| dispatch.start_time + dispatch.duration < _to_dt(end_from) | ||
| ): |
Copilot
AI
Sep 29, 2025
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 condition check order has changed from the original logic. The original code checked dispatch.duration before the time comparison, but the parentheses now group the time comparison separately. Consider moving dispatch.duration check outside the parentheses to maintain the original short-circuit behavior: if dispatch.duration and dispatch.start_time + dispatch.duration < _to_dt(end_from):
| if dispatch.duration and ( | |
| dispatch.start_time + dispatch.duration < _to_dt(end_from) | |
| ): | |
| if dispatch.duration and dispatch.start_time + dispatch.duration < _to_dt(end_from): |
This PR fixes a bug in the
FakeServicefilter implementation where field existence was not properly checked before accessing optional protobuf fields. The fix replaces the walrus operator with explicitHasField()checks to correctly determine if optional fields are set.