Skip to content

Commit bd74b82

Browse files
committed
feat: don't double parse the incoming JSON body when checking if it is invalid.
For @uglyog
1 parent 73db9c2 commit bd74b82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/pact_broker/api/resources/base_resource.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def handle_exception e
8484
end
8585

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

9090
def params_with_string_keys
@@ -123,7 +123,7 @@ def pacticipant_name
123123

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

0 commit comments

Comments
 (0)