Bug #30946

Configuring ActiveRecord::Base.include_root_in_json per response is not thread safe

Added by Eric Helms about 2 years ago. Updated almost 2 years ago.

Target version:
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

Associated revisions

Revision fe7231a5 (diff)
Added by Eric Helms about 2 years ago

Fixes #30946: Use Rails default for JSON root node

Back when the application had a V1 and V2 API, the V2 API needed to
adhere to the designed format. This included not having a root node
in the JSON output for the object being returned. Given the use of
Rabl was not enforced across the ecosystem of plugins, this was
disabled per request for any request that did not go through the
Rabl rendering engine. The configuration that controls this is a
class variable and is thus not thread safe.

To enable the use of a multi-threaded Puma deployment, this setting
has to be set at application boot and not per request. The previous
implementation returned the setting back to it's default value of
true so that the V1 API was unaffected. This has potential consequences
across other areas of code or plugins that relied on the `to_json`
method on a model to perform further manipulations and were coded
to expect the root.

The alternative approach is to avoid setting this setting all together
and drop it's use. The expectation here would be that all API implementations
should be using Rabl templates properly to follow the API V2 spec
and any plugins relying on attempting to render through to_json
will need to fix this or potentiall encounter a change in their
API responses to have the root node.


#1 Updated by The Foreman Bot about 2 years ago

  • Assignee set to Eric Helms
  • Status changed from New to Ready For Testing
  • Pull request added

#2 Updated by The Foreman Bot about 2 years ago

  • Fixed in Releases 2.3.0 added

#3 Updated by Eric Helms about 2 years ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Tomer Brisker about 2 years ago

  • Category set to Rails

#5 Updated by Tomer Brisker almost 2 years ago

  • Bugzilla link set to 1879587

Also available in: Atom PDF