heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
37 stars 8 forks source link

`package_buildpack()` and `package_crate_buildpack()` contain `asserts!` even though they return `Result`s #709

Closed edmorley closed 12 months ago

edmorley commented 1 year ago

Currently these functions mix and match assertions and returning Result: https://github.com/heroku/libcnb.rs/blob/2698a713edf19034e382aa702e12acc1516da8fa/libcnb-test/src/build.rs#L15-L27 https://github.com/heroku/libcnb.rs/blob/2698a713edf19034e382aa702e12acc1516da8fa/libcnb-test/src/build.rs#L74-L78

These were introduced as part of #666, and are part of the reason that the regression in #704 was able to sneak in (since it means the tests circumvent the top level error handling that was broken in #666).

They should be converted to additional error types and returned as an error instead.

There's also a lint we can use to prevent this in the future: https://rust-lang.github.io/rust-clippy/master/index.html#/panic_in_result_fn (in addition to panics, it detects assertions in result functions)