Skip to content

Commit de7edd5

Browse files
authored
fix: suppress config deprecation stderr in JSON mode globally (#824)
Add SUPPRESS_CONFIG_WARNINGS_STDERR AtomicBool flag in runtime/config.rs and expose suppress_config_warnings_for_json_mode() via runtime crate. In main.rs, scan raw argv for --output-format json before parse_args and activate the flag so no settings-load warnings reach stderr on any JSON-mode surface (status, sandbox, system-prompt, mcp list, skills list, agents list, --resume /config*, etc.). Text-mode surfaces are unaffected; prose deprecation warnings continue to appear on stderr. All 572+ tests pass (one pre-existing worker_boot failure unrelated).
1 parent f0e6671 commit de7edd5

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

rust/crates/runtime/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ use std::sync::Mutex;
1010
static EMITTED_CONFIG_WARNINGS: std::sync::OnceLock<Mutex<HashSet<String>>> =
1111
std::sync::OnceLock::new();
1212

13+
/// When set to `true`, `emit_config_warning_once` silently drops all prose
14+
/// deprecation warnings instead of writing them to stderr. Set this flag
15+
/// before any settings load when `--output-format json` is active so that
16+
/// JSON-mode machine consumers see empty stderr on success. (#824)
17+
static SUPPRESS_CONFIG_WARNINGS_STDERR: std::sync::atomic::AtomicBool =
18+
std::sync::atomic::AtomicBool::new(false);
19+
20+
/// Call this once at startup when `--output-format json` is active.
21+
pub fn suppress_config_warnings_for_json_mode() {
22+
SUPPRESS_CONFIG_WARNINGS_STDERR.store(true, std::sync::atomic::Ordering::Relaxed);
23+
}
24+
1325
fn emit_config_warning_once(warning: &str) {
26+
if SUPPRESS_CONFIG_WARNINGS_STDERR.load(std::sync::atomic::Ordering::Relaxed) {
27+
return;
28+
}
1429
let set = EMITTED_CONFIG_WARNINGS.get_or_init(|| Mutex::new(HashSet::new()));
1530
let mut guard = set.lock().unwrap_or_else(|e| e.into_inner());
1631
if guard.insert(warning.to_string()) {

rust/crates/runtime/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ pub use compact::{
6565
get_compact_continuation_message, should_compact, CompactionConfig, CompactionResult,
6666
};
6767
pub use config::{
68-
ConfigEntry, ConfigError, ConfigLoader, ConfigSource, McpConfigCollection,
69-
McpManagedProxyServerConfig, McpOAuthConfig, McpRemoteServerConfig, McpSdkServerConfig,
70-
McpServerConfig, McpStdioServerConfig, McpTransport, McpWebSocketServerConfig, OAuthConfig,
71-
ProviderFallbackConfig, ResolvedPermissionMode, RuntimeConfig, RuntimeFeatureConfig,
72-
RuntimeHookConfig, RuntimePermissionRuleConfig, RuntimePluginConfig, ScopedMcpServerConfig,
73-
CLAW_SETTINGS_SCHEMA_NAME,
68+
suppress_config_warnings_for_json_mode, ConfigEntry, ConfigError, ConfigLoader, ConfigSource,
69+
McpConfigCollection, McpManagedProxyServerConfig, McpOAuthConfig, McpRemoteServerConfig,
70+
McpSdkServerConfig, McpServerConfig, McpStdioServerConfig, McpTransport,
71+
McpWebSocketServerConfig, OAuthConfig, ProviderFallbackConfig, ResolvedPermissionMode,
72+
RuntimeConfig, RuntimeFeatureConfig, RuntimeHookConfig, RuntimePermissionRuleConfig,
73+
RuntimePluginConfig, ScopedMcpServerConfig, CLAW_SETTINGS_SCHEMA_NAME,
7474
};
7575
pub use config_validate::{
7676
check_unsupported_format, format_diagnostics, validate_config_file, ConfigDiagnostic,

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,16 @@ fn plugin_load_failure_json(failure: &plugins::PluginLoadFailure) -> Value {
532532

533533
fn run() -> Result<(), Box<dyn std::error::Error>> {
534534
let args: Vec<String> = env::args().skip(1).collect();
535+
// #824: suppress config deprecation prose warnings to stderr when JSON
536+
// output mode is active. Scan the raw argv before parse_args so the
537+
// suppression is in place before any settings file is loaded.
538+
let json_mode = args
539+
.windows(2)
540+
.any(|w| w[0] == "--output-format" && w[1] == "json")
541+
|| args.iter().any(|a| a == "--output-format=json");
542+
if json_mode {
543+
runtime::suppress_config_warnings_for_json_mode();
544+
}
535545
match parse_args(&args)? {
536546
CliAction::DumpManifests {
537547
output_format,

0 commit comments

Comments
 (0)