Skip to content

Fix empty data on MapTraceEvent and log input values of rust functions on error#984

Merged
edenhaus merged 9 commits into
devfrom
fix_empty_tracemapevent
May 23, 2025
Merged

Fix empty data on MapTraceEvent and log input values of rust functions on error#984
edenhaus merged 9 commits into
devfrom
fix_empty_tracemapevent

Conversation

@edenhaus

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 21, 2025 15:00
@edenhaus edenhaus added the pr: bugfix PR, which fixes a bug label May 21, 2025
@codecov

codecov Bot commented May 21, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.65%. Comparing base (2685f6b) to head (9a4bb5f).
Report is 2 commits behind head on dev.

✅ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented May 21, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #984 will not alter performance

Comparing fix_empty_tracemapevent (9a4bb5f) with dev (5c8c905)

Summary

✅ 6 untouched benchmarks

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/util.rs Outdated
Comment thread src/map.rs Outdated
Comment thread src/map.rs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@edenhaus edenhaus requested a review from Copilot May 21, 2025 16:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.data in the Python listener and a corresponding test.
  • Refactor Rust functions (decompress_base64_data, extract_trace_points, update_points) to take &str instead of String.
  • 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.

Comment thread tests/test_map.py
Comment thread src/util.rs Outdated
Comment thread src/map.rs Outdated
Comment thread src/map.rs Outdated
Comment thread deebot_client/map.py Outdated
edenhaus and others added 3 commits May 21, 2025 17:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@edenhaus edenhaus requested a review from Copilot May 23, 2025 07:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_points when event.data is blank.
  • Change Rust functions to accept &str and 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 map shadows the built-in map function; consider renaming it to something like map_instance or map_obj to 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.data leads to add_trace_points being called; consider adding a complementary test where event.data contains non-whitespace to assert that add_trace_points is invoked.
async def test_empty_maptrace(

Comment thread src/map.rs Outdated
Comment thread deebot_client/map.py Outdated
@edenhaus

Copy link
Copy Markdown
Member Author

pre-commit.ci autofix

pre-commit-ci Bot and others added 3 commits May 23, 2025 07:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@edenhaus edenhaus changed the title Fix empty data on MapTraceEvent Fix empty data on MapTraceEvent and log input values of rust functions on error May 23, 2025
@edenhaus edenhaus merged commit 1915a1f into dev May 23, 2025
27 checks passed
@edenhaus edenhaus deleted the fix_empty_tracemapevent branch May 23, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: bugfix PR, which fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants