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 +++--- crates/shirabe/src/repository/vcs/forgejo_driver.rs | 2 +- crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs | 2 +- crates/shirabe/src/repository/vcs/github_driver.rs | 2 +- crates/shirabe/src/repository/vcs/gitlab_driver.rs | 2 +- crates/shirabe/src/repository/vcs/svn_driver.rs | 2 +- crates/shirabe/src/repository/vcs/vcs_driver.rs | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/repository') 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); diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index 49d0dcf1..0719701f 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -364,7 +364,7 @@ impl ForgejoDriver { pretty_print: false, ..Default::default() }, - ); + )?; self.inner .cache .as_mut() diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 95d29938..394077e9 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -281,7 +281,7 @@ impl GitBitbucketDriver { pretty_print: false, ..Default::default() }, - ), + )?, )?; } } diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index c7fe5266..8134a16b 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -303,7 +303,7 @@ impl GitHubDriver { pretty_print: false, ..Default::default() }, - ), + )?, ) }); } diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 8d100755..9a4c22a1 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -298,7 +298,7 @@ impl GitLabDriver { pretty_print: false, ..Default::default() }, - ), + )?, ) }); } diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 3c233db8..716b1943 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -227,7 +227,7 @@ impl SvnDriver { pretty_print: false, ..Default::default() }, - ); + )?; self.inner .cache .as_mut() diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index 5aa74959..3321201c 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -171,7 +171,7 @@ impl VcsDriverBase { pretty_print: false, ..Default::default() }, - ); + )?; self.cache.as_mut().map(|c| c.write(identifier, &encoded)); } self.info_cache.insert(identifier.to_string(), composer); @@ -237,7 +237,7 @@ pub trait VcsDriver: VcsDriverInterface { pretty_print: false, ..Default::default() }, - ); + )?; self.cache_mut().map(|c| c.write(identifier, &encoded)); } -- cgit v1.3.1