Project

General

Profile

Bug #30946

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

Added by Eric Helms 7 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Associated revisions

Revision fe7231a5 (diff)
Added by Eric Helms 6 months 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.

History

#1 Updated by The Foreman Bot 7 months ago

  • Assignee set to Eric Helms
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/8037 added

#2 Updated by The Foreman Bot 6 months ago

  • Fixed in Releases 2.3.0 added

#3 Updated by Eric Helms 6 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Tomer Brisker 5 months ago

  • Category set to Rails

#5 Updated by Tomer Brisker 3 months ago

  • Bugzilla link set to 1879587

Also available in: Atom PDF