Skip to content

Commit 8d48898

Browse files
committed
Replace invalid UTF-8 chars when encoding, more targeted rescue, bump version
1 parent 4049dbb commit 8d48898

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/project_pull_mover/gh_cli.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,13 @@ def get_pulls_by_author_in_project
182182

183183
sig { params(input: String).returns(T.untyped) }
184184
def parse_json(input)
185-
JSON.parse(input.encode("UTF-8"))
186-
rescue Encoding::InvalidByteSequenceError => err
187-
raise JsonParseError.new("Could not parse JSON due to invalid byte sequence: #{err.message}", err)
185+
encoded_input = input.encode("UTF-8", invalid: :replace, undef: :replace, replace: "")
186+
begin
187+
JSON.parse(encoded_input)
188+
rescue Encoding::InvalidByteSequenceError => err
189+
raise JsonParseError.new("Could not parse JSON due to invalid byte sequence: #{err.message}\n" \
190+
"Encoded input:\n\n#{encoded_input.inspect}", err)
191+
end
188192
end
189193

190194
sig { returns(T::Boolean) }

lib/project_pull_mover/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# frozen_string_literal: true
33

44
module ProjectPullMover
5-
VERSION = "0.0.7"
5+
VERSION = "0.0.8"
66
end

0 commit comments

Comments
 (0)