Skip to content

Commit

Permalink
fix: duplicate response body before mutating it (dependabot#7926)
Browse files Browse the repository at this point in the history
Addresses the following error that is happening in `main` npm tests :

>
> Failure/Error:
> @project_npm_response.body.force_encoding("UTF-8").encode.
> include?(project_description)
>
>  FrozenError:
>    can't modify frozen String: ""

Example failure : https://github.com/dependabot/dependabot-core/actions/runs/6019388208/job/16329143018?pr=7811
  • Loading branch information
yeikel authored Aug 30, 2023
1 parent 2154d9d commit c6f829c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def npm_response_matches_package_json?
@project_npm_response ||= Dependabot::RegistryClient.get(url: url)
return false unless @project_npm_response.status == 200

@project_npm_response.body.force_encoding("UTF-8").encode.
@project_npm_response.body.dup.force_encoding("UTF-8").encode.
include?(project_description)
rescue Excon::Error::Socket, Excon::Error::Timeout, URI::InvalidURIError
false
Expand Down

0 comments on commit c6f829c

Please sign in to comment.