Skip to content

Commit 7f56bb8

Browse files
chawyehsuniheaven
authored andcommitted
fix(scoop-search): Catch error of parsing invalid manifest (#5930)
1 parent 7474848 commit 7f56bb8

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### Bug Fixes
99

1010
- **json:** Serialize jsonpath return ([#5921](https://github.com/ScoopInstaller/Scoop/issues/5921))
11+
- **scoop-search:** Catch error of parsing invalid manifest ([#5930](https://github.com/ScoopInstaller/Scoop/issues/5930))
1112

1213
## [v0.4.2](https://github.com/ScoopInstaller/Scoop/compare/v0.4.1...v0.4.2) - 2024-05-14
1314

libexec/scoop-search.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ function search_bucket($bucket, $query) {
6161
$apps = Get-ChildItem (Find-BucketDirectory $bucket) -Filter '*.json' -Recurse
6262

6363
$apps | ForEach-Object {
64-
$json = [System.Text.Json.JsonDocument]::Parse([System.IO.File]::ReadAllText($_.FullName))
64+
$filepath = $_.FullName
65+
66+
$json = try {
67+
[System.Text.Json.JsonDocument]::Parse([System.IO.File]::ReadAllText($filepath))
68+
} catch {
69+
debug "Failed to parse manifest file: $filepath (error: $_)"
70+
return
71+
}
72+
6573
$name = $_.BaseName
6674

6775
if ($name -match $query) {

0 commit comments

Comments
 (0)