Skip to content

🧹 Refactor unsafe unwrap() calls in native_emit/uf2.rs tests - #322

Open
undivisible wants to merge 1 commit into
masterfrom
fix/uf2-unwrap-5772482188214198352
Open

🧹 Refactor unsafe unwrap() calls in native_emit/uf2.rs tests#322
undivisible wants to merge 1 commit into
masterfrom
fix/uf2-unwrap-5772482188214198352

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 What: The test functions encodes_single_block_with_family and splits_large_payload in in-cli/src/native_emit/uf2.rs were using unsafe unwrap() and expect() calls, which could cause abrupt panics.
💡 Why: Modifying the test signatures to return Result<(), Box<dyn std::error::Error>> and replacing .unwrap()/.expect() with the ? operator ensures robust error handling and follows idiomatic Rust testing practices without altering test behavior.
Verification: Ran cd in-cli && cargo fmt, cargo clippy --all-targets --features extended --locked -- -D warnings, and cargo test uf2. All test suites pass with no regressions.
Result: Enhanced the maintainability and reliability of the codebase by replacing unsafe panic behavior with idiomatic error propagation.


PR created automatically by Jules for task 5772482188214198352 started by @undivisible


Note

Low Risk
Test-only refactor in native_emit/uf2.rs; no runtime or encoding logic changes.

Overview
Refactors two UF2 encoder unit tests in uf2.rs so they return Result<(), Box<dyn std::error::Error>> instead of panicking via .expect() and .unwrap().

encodes_single_block_with_family and splits_large_payload now propagate failures from encode_uf2 and try_into() with ?, end with Ok(()), and include a small assert layout cleanup. rejects_empty is unchanged and still uses expect_err. Production encode_uf2 behavior is untouched.

Reviewed by Cursor Bugbot for commit 795e97b. Configure here.

…rator

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_948dbd78-30dc-4bcb-8d47-9b39636f4365)

@mergify

mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant