Skip to content

Commit 3eb1f3b

Browse files
christollidayfacebook-github-bot
authored andcommitted
Use tag metadata to specify hidden tags
Summary: Small cleanup to have all tag metadata in one place. Reviewed By: iguridi Differential Revision: D71503397 fbshipit-source-id: e478498333e88ca5f7dc89b1f40dec909f31cda6
1 parent fc1ec02 commit 3eb1f3b

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

app/buck2_error/src/classify.rs

+25-19
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,24 @@ struct TagMetadata {
4141
// If true and an error includes non-generic tags,
4242
// generic tags will be excluded from category key.
4343
generic: bool,
44+
// Hidden tags are only used to determine category,
45+
// they are excluded from both category keys and error_tags
46+
// reported externally.
47+
// These should be removed/avoided if possible.
48+
hidden: bool,
4449
}
4550

4651
impl TagMetadata {
4752
fn generic(self, generic: bool) -> Self {
4853
Self { generic, ..self }
4954
}
55+
56+
fn hidden(self) -> Self {
57+
Self {
58+
hidden: true,
59+
..self
60+
}
61+
}
5062
}
5163

5264
macro_rules! rank {
@@ -56,21 +68,25 @@ macro_rules! rank {
5668
category: Some(Tier::Environment),
5769
rank: line!(),
5870
generic: false,
71+
hidden: false,
5972
},
6073
"tier0" => TagMetadata {
6174
category: Some(Tier::Tier0),
6275
rank: line!(),
6376
generic: false,
77+
hidden: false,
6478
},
6579
"input" => TagMetadata {
6680
category: Some(Tier::Input),
6781
rank: line!(),
6882
generic: false,
83+
hidden: false,
6984
},
7085
"unspecified" => TagMetadata {
7186
category: None,
7287
rank: line!(),
7388
generic: true,
89+
hidden: false,
7490
},
7591
_ => unreachable!(),
7692
}
@@ -94,7 +110,7 @@ fn tag_metadata(tag: ErrorTag) -> TagMetadata {
94110
ErrorTag::ServerStderrEmpty => rank!(environment),
95111
// Note: This is only true internally due to buckwrapper
96112
ErrorTag::NoBuckRoot => rank!(environment),
97-
ErrorTag::InstallerEnvironment => rank!(environment),
113+
ErrorTag::InstallerEnvironment => rank!(environment).hidden(),
98114
ErrorTag::IoNotConnected => rank!(environment), // This typically means eden is not mounted
99115

100116
// Tier 0 errors
@@ -160,10 +176,10 @@ fn tag_metadata(tag: ErrorTag) -> TagMetadata {
160176
ErrorTag::DiceUnexpectedCycleGuardType => rank!(tier0),
161177
ErrorTag::DiceDuplicateActivationData => rank!(tier0),
162178
ErrorTag::InstallerUnknown => rank!(tier0),
163-
ErrorTag::InstallerTier0 => rank!(tier0),
179+
ErrorTag::InstallerTier0 => rank!(tier0).hidden(),
164180

165-
ErrorTag::Environment => rank!(environment),
166-
ErrorTag::Tier0 => rank!(tier0),
181+
ErrorTag::Environment => rank!(environment).hidden(),
182+
ErrorTag::Tier0 => rank!(tier0).hidden(),
167183

168184
// Input errors
169185
// FIXME(JakobDegen): Make this bad experience once that's available. Usually when this
@@ -195,10 +211,10 @@ fn tag_metadata(tag: ErrorTag) -> TagMetadata {
195211
ErrorTag::HttpClient => rank!(input),
196212
ErrorTag::TestDeadlineExpired => rank!(input),
197213
ErrorTag::Unimplemented => rank!(input),
198-
ErrorTag::InstallerInput => rank!(input),
214+
ErrorTag::InstallerInput => rank!(input).hidden(),
199215
ErrorTag::BuildDeadlineExpired => rank!(input),
200216

201-
ErrorTag::Input => rank!(input),
217+
ErrorTag::Input => rank!(input).hidden(),
202218

203219
// Tags with unspecified category, these can represent:
204220
// - Tags not specific enough to determine infra vs user categorization.
@@ -236,23 +252,13 @@ fn tag_metadata(tag: ErrorTag) -> TagMetadata {
236252

237253
/// Errors can be categorized by tags only if they have any non-generic tags.
238254
pub fn tag_is_generic(tag: &ErrorTag) -> bool {
239-
if tag_is_hidden(tag) {
240-
return true;
241-
}
242-
tag_metadata(*tag).generic
255+
let metadata = tag_metadata(*tag);
256+
metadata.generic || metadata.hidden
243257
}
244258

245259
/// Hidden tags only used internally, for categorization.
246260
pub fn tag_is_hidden(tag: &ErrorTag) -> bool {
247-
match tag {
248-
ErrorTag::Tier0 => true,
249-
ErrorTag::Input => true,
250-
ErrorTag::Environment => true,
251-
ErrorTag::InstallerTier0 => true,
252-
ErrorTag::InstallerInput => true,
253-
ErrorTag::InstallerEnvironment => true,
254-
_ => false,
255-
}
261+
tag_metadata(*tag).hidden
256262
}
257263

258264
pub trait ErrorLike {

0 commit comments

Comments
 (0)