ref(rust): Deny unwrap/expect in message processors#7810
Open
ref(rust): Deny unwrap/expect in message processors#7810
Conversation
onewland
commented
Mar 11, 2026
| @@ -1,4 +1,6 @@ | |||
| pub mod eap_items; | |||
| #![deny(clippy::unwrap_used, clippy::expect_used)] | |||
Contributor
Author
There was a problem hiding this comment.
this is the important change
Configure clippy to deny `panic!`, `todo!`, `unimplemented!`, and `unreachable!` macros, preventing future panics in production code. Replace existing panic calls with proper error handling: - config.rs: Return serde deserialization error instead of panicking - factory_v2.rs: Log error and exit instead of panicking - processor.rs: Log error and exit instead of panicking on schema error - python.rs: Return InvalidMessage error instead of panicking - writer_v2.rs: Replace unreachable! with anyhow::bail! Refs EAP-439 Co-Authored-By: Claude <noreply@anthropic.com>
Add `clippy::unwrap_used` and `clippy::expect_used` as deny lints scoped to the processors module, where message processing happens. This would have caught the INC-2060 panic on a missing field. Fix all existing production unwraps in processors: - eap_items: Handle missing `received` field gracefully - eap_items: Return Result from read_item_id instead of panicking - errors: Use unwrap_or_else for UUID fallback - generic_metrics: Use filter_map for tag key parsing - release_health_metrics: Use filter_map for tag key parsing Test code is exempted via #[allow] on test modules. Refs EAP-439 Co-Authored-By: Claude <noreply@anthropic.com>
…umers" This reverts commit 9bfb4d6.
be78b85 to
e639ac8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Fix split_at panic in read_item_id by using .get() with proper error handling. Fix filter_map silently dropping unparseable tag keys which could create mismatched parallel arrays — use map+collect with error propagation instead. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
Also fixes EAP-438 |
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.
Deny
clippy::unwrap_usedandclippy::expect_usedin theprocessorsmodule, where message processing happens. This is where bad input data is most likely to trigger panics — like INC-2060 where.unwrap()on a missing field caused a panic.All existing production unwraps in processors are fixed:
eap_items: Handle missingreceivedfield gracefully (the exact INC-2060 bug)eap_items: ReturnResultfromread_item_idinstead of panickingerrors: Useunwrap_or_elsefor UUID fallbackgeneric_metrics/release_health_metrics: Usefilter_mapfor tag key parsingTest code is exempted via
#[allow]on test modules.Refs EAP-439, EAP-438