Skip to content

Commit

Permalink
Fix buck2_error->Starlark TypedContext conversion
Browse files Browse the repository at this point in the history
Summary: Fix the bug mentioned in the previous diff. Root context is no longer dropped and the duplicated error message is correctly de-dup'd

Reviewed By: JakobDegen

Differential Revision: D68535865

fbshipit-source-id: df2a3b8c167777bd98e46feacb8c76b8f6821405
  • Loading branch information
Will-MingLun-Li authored and facebook-github-bot committed Jan 24, 2025
1 parent 0f9c49c commit 56b782f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/buck2_error/src/starlark_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn error_with_starlark_context(
}
ErrorKind::WithContext(context_value, inner) => {
match context_value {
ContextValue::Dyn(_) => {
ContextValue::Dyn(_) | ContextValue::Typed(_) => {
let mut inner_err = inner.clone();
for context in context_stack.into_iter().rev() {
inner_err = inner_err.context(context);
Expand All @@ -97,7 +97,9 @@ fn error_with_starlark_context(
ContextValue::StarlarkError(_) => {
return buck2_error.context_for_starlark_backtrace(starlark_context);
}
_ => context_stack.push(context_value.clone()),
ContextValue::Tags(_) | ContextValue::Key(_) => {
context_stack.push(context_value.clone())
}
}

buck2_error = inner.clone();
Expand Down Expand Up @@ -362,7 +364,7 @@ mod tests {

assert!(starlark_err_string.contains(starlark_call_stack));
assert!(starlark_err_string.contains(starlark_error_msg));
// FIXME(minglunli): Root error shouldn't be lost
assert!(!starlark_err_string.contains(base_error));
// Root error shouldn't be lost
assert!(starlark_err_string.contains(base_error));
}
}

0 comments on commit 56b782f

Please sign in to comment.