Fix empty data on MapTraceEvent and log input values of rust functions on error#984
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## dev #984 +/- ##
==========================================
+ Coverage 93.64% 93.65% +0.01%
==========================================
Files 129 129
Lines 5000 5012 +12
Branches 326 327 +1
==========================================
+ Hits 4682 4694 +12
Misses 258 258
Partials 60 60 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #984 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Pull Request Overview
This PR addresses handling of empty data in MapTraceEvent and improves parameter passing and error reporting for map trace-related functions. Key changes include:
- Adding a new test to ensure that empty MapTraceEvent data does not trigger trace point updates.
- Changing functions in src/util.rs and src/map.rs to accept &str rather than owned String types, improving efficiency.
- Enhancing error messages in both rust modules to include input context for easier debugging.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_map.py | Adds a test to verify that empty trace event data is handled without processing trace points. |
| src/util.rs | Modifies decompress_base64_data and related error handling to take &str and append input info in error messages. |
| src/map.rs | Updates functions for trace point extraction and update, switching to &str parameters and enhancing error messages. |
| deebot_client/map.py | Adjusts trace event handling to process data only when it is provided. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that empty trace data events don’t trigger errors and refactors several APIs to accept &str for efficiency and improved error context.
- Add a guard for empty
MapTraceEvent.datain the Python listener and a corresponding test. - Refactor Rust functions (
decompress_base64_data,extract_trace_points,update_points) to take&strinstead ofString. - Enrich error messages with contextual data in both Python and Rust layers.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/test_map.py | Added test_empty_maptrace and imported patch for mocking. |
| src/util.rs | Changed signature to &str and wrapped errors with value context. |
| src/map.rs | Updated functions to use &str and added detailed error formatting. |
| deebot_client/map.py | Skips add_trace_points when event.data is empty. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that empty MapTraceEvent data does not trigger trace point addition, improves error logging in Rust modules, and updates several functions to borrow &str for efficiency.
- Skip calling
add_trace_pointswhenevent.datais blank. - Change Rust functions to accept
&strand log errors before raising Python exceptions. - Add new tests covering empty trace events and invalid Rust-side map data updates.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_map.py | Add test_empty_maptrace, import patch, and assert no calls on empty data |
| tests/rs/test_map.py | New parameterized tests for invalid add_trace_points and update_map_piece with log assertions |
| src/util.rs | Change decompress_base64_data and Python wrapper to &str, add error logging |
| src/map.rs | Update signatures to &str, insert error! logs in trace & piece update methods |
| deebot_client/map.py | Add guard to skip add_trace_points when event.data.strip() is empty |
Comments suppressed due to low confidence (2)
tests/test_map.py:198
- [nitpick] Variable name
mapshadows the built-inmapfunction; consider renaming it to something likemap_instanceormap_objto improve readability.
map = await setup_map(execute_mock, event_bus, static_device_info)
tests/test_map.py:191
- No test currently verifies that non-empty
event.dataleads toadd_trace_pointsbeing called; consider adding a complementary test whereevent.datacontains non-whitespace to assert thatadd_trace_pointsis invoked.
async def test_empty_maptrace(
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.