facebook / facebook/buck2

Print target when selects fail to match on toolchain targets

Open
#733 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

When a select expression fails to match on a toolchain target, the error message tells you the name of attribute which failed to match but not the target that attribute was on:

```
BUILD FAILED
configuring attr `compiler_flags`
```

The below patch modifies this message to include the target.

```patch
diff --git a/app/buck2_configured/src/nodes/calculation.rs b/app/buck2_configured/src/nodes/calculation.rs
index b3e0e9686f..1cee0384f3 100644
--- a/app/buck2_configured/src/nodes/calculation.rs
+++ b/app/buck2_configured/src/nodes/calculation.rs
@@ -723,7 +723,13 @@ async fn gather_deps(

let mut traversal = Traversal::default();
for a in target_node.attrs(AttrInspectOptions::All) {
- let configured_attr = a.configure(attr_cfg_ctx)?;
+ let configured_attr = a.configure(attr_cfg_ctx).with_context(|| {
+ format!(
+ "configuring attr `{}` for target `{}`",
+ a.name,
+ target_node.label()
+ )
+ })?;
configured_attr.traverse(target_node.label().pkg(), &mut traversal)?;
}

diff --git a/app/buck2_node/src/attrs/coerced_attr_full.rs b/app/buck2_node/src/attrs/coerced_attr_full.rs
index b90008c53f..712469a436 100644
--- a/app/buck2_node/src/attrs/coerced_attr_full.rs
+++ b/app/buck2_node/src/attrs/coerced_attr_full.rs
@@ -31,10 +31,7 @@ impl<'a> CoercedAttrFull<'a> {
Ok(ConfiguredAttrFull {
name: self.name,
attr: self.attr,
- value: self
- .value
- .configure(self.attr.coercer(), ctx)
- .with_context(|| format!("configuring attr `{}`", self.name))?,
+ value: self.value.configure(self.attr.coercer(), ctx)?,
})
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.