-
Notifications
You must be signed in to change notification settings - Fork 470
Deny anyhow #32135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Deny anyhow #32135
Conversation
Denies the use of the anyhow `anyhow` and `bail` macros, which are the main entry points to anyhow. It does not prevent using the error/result types as they're often just passed through. Part of MaterializeInc/database-issues#9092 Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The risks outlined in https://github.com/MaterializeInc/database-issues/issues/9092 seem reasonable, but we should also make the path forward very obvious to anyone touching the code because it might be surprising that anyhow
is to be avoided.
Following the deprecation warnings, we should be able to answer:
- If someone is writing net-new error handling code, what does it look like in absence of
anyhow
? Are there any references to model after? - If someone needs to update the existing code, what should they do?
@@ -88,9 +88,12 @@ disallowed-macros = [ | |||
{ path = "proptest::prop_oneof", reason = "use `proptest::strategy::Union::new` instead" }, | |||
{ path = "log::log", reason = "use the macros provided by `tracing` instead (database-issues#3001)" }, | |||
{ path = "tracing::instrument", reason = "use `mz_ore::instrument` instead" }, | |||
{ path = "anyhow::anyhow", reason = "use structured errors instead" }, | |||
{ path = "anyhow::bail", reason = "use structured errors instead" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo this would be more valuable with a fleshed out example to point people towards
@@ -7,6 +7,9 @@ | |||
// the Business Source License, use of this software will be governed | |||
// by the Apache License, Version 2.0. | |||
|
|||
// database-issues#9092: anyhow should not be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the breadcrumb trail here should also lead folks to the right solution
Deny access to anyhow macros and some types
Deny access to the anyhow macros
anyhow
andbail
, and theResult
type. This covers most of our use of anyhow where we're not just passing errors around.We could also deny
anyhow::Error
, but that would need us to silence another 1000+ warnings, which I feel has diminishing returns: we're mostly interested to finding places where we construct errors, which are covered by this change. Unfortunately, anyhow allows silent error conversion, meaning any?
operator can convert from an error toanyhow
, so we should eventually denyanyhow::Error
, too.In support of MaterializeInc/database-issues#9092
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.