Grape raises Grape::Exceptions::InvalidMessageBody when content-type is missing
Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/545433
Oj::ParseError: invalid escaped character (after variables.userEmail) at line 1, column 1361 [parse.c:312]
from multi_json (1.14.1) lib/multi_json/adapters/oj.rb:34:in `load'
from multi_json (1.14.1) lib/multi_json/adapters/oj.rb:34:in `load'
from multi_json (1.14.1) lib/multi_json/adapter.rb:21:in `load'
from multi_json (1.14.1) lib/multi_json.rb:122:in `load'
from grape (2.0.0) lib/grape/parser/json.rb:8:in `call'
from grape (2.0.0) lib/grape/middleware/formatter.rb:104:in `read_rack_input'
from grape (2.0.0) lib/grape/middleware/formatter.rb:90:in `read_body_input'
from grape (2.0.0) lib/grape/middleware/formatter.rb:20:in `before'
from grape (2.0.0) lib/grape/middleware/base.rb:34:in `call!'
from grape (2.0.0) lib/grape/middleware/base.rb:29:in `call'
from grape (2.0.0) lib/grape/middleware/base.rb:36:in `call!'
from grape (2.0.0) lib/grape/middleware/base.rb:29:in `call'
Grape::Exceptions::InvalidMessageBody:
Problem:
message body does not match declared format
Resolution:
when specifying application/json as content-type, you must pass valid application/json in the request's 'body'
from grape (2.0.0) lib/grape/parser/json.rb:11:in `rescue in call'
from grape (2.0.0) lib/grape/parser/json.rb:7:in `call'
from grape (2.0.0) lib/grape/middleware/formatter.rb:104:in `read_rack_input'
from grape (2.0.0) lib/grape/middleware/formatter.rb:90:in `read_body_input'
from grape (2.0.0) lib/grape/middleware/formatter.rb:20:in `before'
from grape (2.0.0) lib/grape/middleware/base.rb:34:in `call!'
from grape (2.0.0) lib/grape/middleware/base.rb:29:in `call'
from grape (2.0.0) lib/grape/middleware/base.rb:36:in `call!'
from grape (2.0.0) lib/grape/middleware/base.rb:29:in `call'
The error occurrence correlates with grape gem update to version 2.0: !140784 (merged).
Possible related discussion: https://github.com/ruby-grape/grape/issues/2281