From 7e31bab9ff7209c9b6d7928a581d7a449846f42e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Aug 2026 17:32:43 +0900 Subject: fix(json): propagate JsonFile::encode errors instead of unwrapping PHP's JsonFile::encode throws a RuntimeException when json_encode fails; the port swallowed that into an .unwrap() marked TODO(phase-c). Return anyhow::Result from encode/encode_with_options and propagate at every call site (print_table and list_repositories become Result-returning to carry it). Co-Authored-By: Claude Fable 5 --- crates/shirabe/src/repository/composer_repository.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/repository/composer_repository.rs') diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 015a278e..c15c6e12 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -2874,7 +2874,7 @@ impl ComposerRepository { .map(|(k, v)| (k.clone(), v.clone())) .collect(), ); - json = JsonFile::encode_with_options(&as_mixed, JsonEncodeOptions::none()); + json = JsonFile::encode_with_options(&as_mixed, JsonEncodeOptions::none())?; } self.cache.borrow_mut().write(ck, &json); } @@ -3054,7 +3054,7 @@ impl ComposerRepository { data.insert("last-modified".to_string(), PhpMixed::String(lmd.clone())); let as_mixed = PhpMixed::Array(data.iter().map(|(k, v)| (k.clone(), v.clone())).collect()); - json = JsonFile::encode_with_options(&as_mixed, JsonEncodeOptions::none()); + json = JsonFile::encode_with_options(&as_mixed, JsonEncodeOptions::none())?; } if !self.cache.borrow().is_read_only() { self.cache.borrow_mut().write(cache_key, &json); @@ -3229,7 +3229,7 @@ impl ComposerRepository { pretty_print: false, ..Default::default() }, - ); + )?; } if !self.cache.borrow().is_read_only() { self.cache.borrow_mut().write(cache_key, &json); -- cgit v1.3.1