Skip to content

Commit

Permalink
feat: don't double parse the incoming JSON body when checking if it i…
Browse files Browse the repository at this point in the history
…s invalid.

For @uglyog
  • Loading branch information
bethesque committed Feb 12, 2020
1 parent 73db9c2 commit bd74b82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/api/resources/base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def handle_exception e
end

def params
@params ||= JSON.parse(request.body.to_s, {symbolize_names: true}.merge(PACT_PARSING_OPTIONS))
@params ||= JSON.parse(request.body.to_s, { symbolize_names: true }.merge(PACT_PARSING_OPTIONS)) #Not load! Otherwise it will try to load Ruby classes.
end

def params_with_string_keys
Expand Down Expand Up @@ -123,7 +123,7 @@ def pacticipant_name

def invalid_json?
begin
JSON.parse(request_body, PACT_PARSING_OPTIONS) #Not load! Otherwise it will try to load Ruby classes.
params
false
rescue StandardError => e
logger.info "Error parsing JSON #{e} - #{request_body}"
Expand Down

0 comments on commit bd74b82

Please sign in to comment.