From 23d55ced727ea954bc42a025ca0f146554efc4dd Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Wed, 1 May 2024 00:52:49 +0800 Subject: [PATCH] fix(scoop-search): Catch error of parsing invalid manifest (#5930) --- CHANGELOG.md | 1 + libexec/scoop-search.ps1 | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3065fa7a72..aa5314ce26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bug Fixes - **json:** Serialize jsonpath return ([#5921](https://github.com/ScoopInstaller/Scoop/issues/5921)) +- **scoop-search:** Catch error of parsing invalid manifest ([#5930](https://github.com/ScoopInstaller/Scoop/issues/5930)) ## [v0.4.1](https://github.com/ScoopInstaller/Scoop/compare/v0.4.0...v0.4.1) - 2024-04-25 diff --git a/libexec/scoop-search.ps1 b/libexec/scoop-search.ps1 index be044513c1..4254099989 100644 --- a/libexec/scoop-search.ps1 +++ b/libexec/scoop-search.ps1 @@ -61,7 +61,15 @@ function search_bucket($bucket, $query) { $apps = Get-ChildItem (Find-BucketDirectory $bucket) -Filter '*.json' -Recurse $apps | ForEach-Object { - $json = [System.Text.Json.JsonDocument]::Parse([System.IO.File]::ReadAllText($_.FullName)) + $filepath = $_.FullName + + $json = try { + [System.Text.Json.JsonDocument]::Parse([System.IO.File]::ReadAllText($filepath)) + } catch { + debug "Failed to parse manifest file: $filepath (error: $_)" + return + } + $name = $_.BaseName if ($name -match $query) {