Skip to content

Commit 0a5ca11

Browse files
committed
Parameterize soft_error! OSS behavior based on deprecation flag
Only treat deprecation soft errors as hard errors in OSS builds. Non-deprecation soft errors (used for logging) now return Ok in OSS, matching FB internal behavior and preventing panics at .unwrap() sites. Made-with: Cursor
1 parent bfba8cc commit 0a5ca11

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

app/buck2_env/src/soft_error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ pub fn handle_soft_error(
274274
options.quiet = false;
275275
}
276276

277+
let is_deprecation = options.deprecation;
278+
277279
// We want to limit each error to appearing at most 10 times in a build (no point spamming people)
278280
if count.fetch_add(1, Ordering::SeqCst) < 10 {
279281
if let Some(handler) = HANDLER.get() {
@@ -291,6 +293,14 @@ pub fn handle_soft_error(
291293
return Err(err.context("Upgraded warning to failure via $BUCK2_HARD_ERROR"));
292294
}
293295

296+
// @oss-disable: let is_open_source = false;
297+
let is_open_source = true; // @oss-enable
298+
if is_open_source && is_deprecation {
299+
// Deprecation warnings should be hard errors in OSS since there are
300+
// no legacy users that need the grace period.
301+
return Err(err);
302+
}
303+
294304
Ok(err)
295305
}
296306

0 commit comments

Comments
 (0)