Skip to content

Commit fc1ec02

Browse files
christollidayfacebook-github-bot
authored andcommitted
Allow tags without specified category to be 'non-generic'
Summary: Most 'unspecified' tags (tags associated with both input and infra errors) should be excluded from category keys ('generic'), but not all. IO_EDEN should be unspecified but not generic in order to correctly attribute eden errors (via source_area). Reviewed By: iguridi Differential Revision: D71503398 fbshipit-source-id: 7b2bb2da7b82e1f81dbd9fda56f1dc2d87ad487e
1 parent bbcbb65 commit fc1ec02

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

app/buck2_error/src/classify.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ pub enum Tier {
3838
struct TagMetadata {
3939
category: Option<Tier>,
4040
rank: u32,
41+
// If true and an error includes non-generic tags,
42+
// generic tags will be excluded from category key.
43+
generic: bool,
44+
}
45+
46+
impl TagMetadata {
47+
fn generic(self, generic: bool) -> Self {
48+
Self { generic, ..self }
49+
}
4150
}
4251

4352
macro_rules! rank {
@@ -46,18 +55,22 @@ macro_rules! rank {
4655
"environment" => TagMetadata {
4756
category: Some(Tier::Environment),
4857
rank: line!(),
58+
generic: false,
4959
},
5060
"tier0" => TagMetadata {
5161
category: Some(Tier::Tier0),
5262
rank: line!(),
63+
generic: false,
5364
},
5465
"input" => TagMetadata {
5566
category: Some(Tier::Input),
5667
rank: line!(),
68+
generic: false,
5769
},
5870
"unspecified" => TagMetadata {
5971
category: None,
6072
rank: line!(),
73+
generic: true,
6174
},
6275
_ => unreachable!(),
6376
}
@@ -187,18 +200,19 @@ fn tag_metadata(tag: ErrorTag) -> TagMetadata {
187200

188201
ErrorTag::Input => rank!(input),
189202

190-
// Generic tags, these can represent:
203+
// Tags with unspecified category, these can represent:
191204
// - Tags not specific enough to determine infra vs user categorization.
192205
// - Tags not specific enough to usefully disambiguate category keys.
193206
// - Something that isn't actually an error.
194207
// - A phase of the build.
208+
// By default these are generic (excluded from category keys)
195209
ErrorTag::ClientGrpc => rank!(unspecified),
196210
ErrorTag::IoBrokenPipe => rank!(unspecified),
197211
ErrorTag::IoWindowsSharingViolation => rank!(unspecified),
198212
ErrorTag::IoNotFound => rank!(unspecified),
199213
ErrorTag::IoSource => rank!(unspecified),
200214
ErrorTag::IoSystem => rank!(unspecified),
201-
ErrorTag::IoEden => rank!(unspecified),
215+
ErrorTag::IoEden => rank!(unspecified).generic(false),
202216
ErrorTag::IoEdenConnectionError => rank!(unspecified),
203217
ErrorTag::IoEdenRequestError => rank!(unspecified),
204218
ErrorTag::IoEdenUnknownField => rank!(unspecified),
@@ -225,7 +239,7 @@ pub fn tag_is_generic(tag: &ErrorTag) -> bool {
225239
if tag_is_hidden(tag) {
226240
return true;
227241
}
228-
tag_metadata(*tag).category.is_none()
242+
tag_metadata(*tag).generic
229243
}
230244

231245
/// Hidden tags only used internally, for categorization.

tests/core/build/test_error_categorization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,4 @@ async def test_eden_io_error_tagging(buck: Buck, tmp_path: Path) -> None:
402402
[error] = errors
403403

404404
assert "IO_EDEN" in error["tags"]
405-
assert error["category_key"] == "IO_PERMISSION_DENIED"
405+
assert error["category_key"] == "IO_EDEN:IO_PERMISSION_DENIED"

0 commit comments

Comments
 (0)