fix(codegen): replace unsafe unwraps with error context and robust ma…#80
Open
goodbsw wants to merge 2 commits into
Open
fix(codegen): replace unsafe unwraps with error context and robust ma…#80goodbsw wants to merge 2 commits into
goodbsw wants to merge 2 commits into
Conversation
…tching Signed-off-by: Seungweon Baek <goodbsw@gmail.com>
Signed-off-by: Seungweon Baek <goodbsw@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses latent panic risks within the
k8s-pb-codegenbinary by refactoring aggressive.unwrap()calls into idiomatic Rust error-handling patterns usinganyhow::Context.As an infrastructure engineering component, the code generator should gracefully bubble up errors rather than inducing unexpected panics during build time, especially within multi-cluster CI/CD pipelines.
Key Changes
unwrap()in Module Tree Traversal: Refactored thewhile !parts.is_empty()loop to use an atomicwhile let Some(module) = parts.pop()pattern, preventing potential index or bounds panics structurally..with_context()tracking to alldst.parent()resolutions andstd::fs::create_dir_allcalls to provide granular diagnosis if I/O blockages occur.append_trait_defandappend_trait_implto returnanyhow::Result<()>. Replacedwriteln!(...).unwrap()with?propagation to catch disk capacity or broken pipe anomalies gracefully.prost_buildPropagation: Aligned the Protobuf compilation phase with consistentanyhowcontext mapping.Diagnostics Verified
Successfully validated workspace compilation against all targets:
cargo check --workspace --all-targets # Output: Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s