Defect #44428
closedJSON API requests fail with JSON gem 3.0.0
Description
After updating the json gem to 3.0.0, JSON API requests with a request body (POST/PUT) fail, and many API tests fail with the following error:
Error:
Redmine::ApiTest::IssuesTest#test_GET_/issues/:id.json_with_no_spent_time_should_return_floats:
ArgumentError: wrong number of arguments (given 2, expected 1)
test/integration/api_test/issues_test.rb:371:in 'block in <class:IssuesTest>'
This is caused by an incompatibility between json 3.0.0 and ActiveSupport in Rails 8.1.3.1. Rails has already fixed it in rails/rails#58601, but no Rails release includes the fix yet.
Currently, only trunk is affected. In 7.0-stable and 6.1-stable, the older RuboCop versions depend on json ~> 2.3, which prevents json 3.0.0 from being installed. Trunk uses RuboCop 1.90.0, which relaxed the requirement to json >= 2.3, so bundle update now installs json 3.0.0.
Until a Rails version containing the fix is released, json should be pinned to 2.x in the Gemfile:
gem "json", "< 3.0"
Related issues
Updated by Go MAEDA 23 days ago
I am planning to do the following:
- When a Rails 8.1 release that includes rails/rails#58601 is available, update Rails in trunk and 7.0-stable. The pin in trunk will be removed at the same time.
- At the same time, backport the pin to 6.1-stable. Rails 7.2 is no longer maintained, so 6.1-stable will not get a fixed Rails version.
Updated by Go MAEDA 3 days ago
- Status changed from Resolved to Closed
- Target version deleted (
6.1.5)
Rails 8.1.4 and 7.2.4 have been released. Both fix the incompatibility with the JSON 3.0 gem.
Rails has been updated to 8.1.4 in trunk and 7.0-stable (#44523), and to 7.2.4 in 6.1-stable (#44524). The workaround in r25052, which pinned the JSON gem below 3.0 in trunk, is no longer needed, so I reverted it in r25148.
Closing this issue.
Updated by Go MAEDA 3 days ago
- Related to Patch #44523: Update Rails to 8.1.4 added
- Related to Patch #44524: Update Rails to 7.2.4 added