Skip to content

🧹 Fix unsafe unwrap() usage in native_emit::uf2 tests - #324

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

🧹 Fix unsafe unwrap() usage in native_emit::uf2 tests#324
undivisible wants to merge 1 commit into
masterfrom
fix-uf2-unwrap-10215781581313917983

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 What:
Replaced unwrap() and expect() usage in in-cli/src/native_emit/uf2.rs test assertions with safe error propagation using the ? operator by changing the test functions to return Result<(), Box<dyn std::error::Error>>.

💡 Why:
Unsafe unwrap usage inside tests is generally acceptable, but converting test signatures to return a Result allows leveraging the ? operator. This makes the testing code more idiomatic, prevents hard panics, and aligns with standard Rust error handling practices.

Verification:

  • Verified that cargo test -p inauguration native_emit::uf2 passes correctly.
  • Checked that there are no regressions across the rest of the crate using cargo test.
  • Validated overall project health and integration using the local install and testing script IN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in test.
  • Ensured formatting and clippy rules are strictly met with cargo fmt and cargo clippy.

Result:
The UF2 tests are cleaner and handle try_into() and encode_uf2() errors gracefully without relying on panicking unwrap() mechanisms.


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


Note

Low Risk
Test-only refactors in uf2.rs; no changes to encode_uf2 or write_uf2 behavior.

Overview
Updates the encodes_single_block_with_family and splits_large_payload tests in uf2.rs so they return Result<(), Box<dyn std::error::Error>> instead of panicking on failure paths.

encode_uf2 and slice try_into() failures now propagate with ?, and successful runs end with Ok(()). The empty-payload test still uses expect_err for the error case. Production UF2 encoding is unchanged.

Reviewed by Cursor Bugbot for commit d592f65. Configure here.

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_4649b62b-7081-4c89-9026-7bdb5176534f)

@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