Skip to content

Commit 23f0be6

Browse files
Upgrade from Rails 8.0.5 to 8.1.3 (#6335)
* Fix LogTicket model scope single record semantics Co-authored-by: Colby Swandale <colby@rubygems.org> * Add missing test coverage for Types::JsonDeserializable class * Upgrade from Rails 8.0.5 to 8.1.3 Includes the following changes: - Updated Gemfile and Gemfile.lock accordingly for the upgrade. - Reordered schema to be sorted alphabetically re: rails/rails#53281. - Removes connection_pool lock to 2.x and bumps it from 2.5.5 to 3.0.2 as Rails 8.1.2 supports 3.x. * Add normalization for array/hash subclasses during JSON serialization Due to Rails 8.1 migrating from JSONGemEncoder to JSONGemCoderEncoder, of which the latter calls as_json on Array/Hash subclasses and thus can produce unexpected structures (e.g. JSON::JWK::Set#as_json returns {keys: [...]} instead of a plain array), we appear to need normalization at serialization boundaries before JSON encoding. --------- Co-authored-by: Colby Swandale <colby@rubygems.org>
1 parent 72312b4 commit 23f0be6

File tree

8 files changed

+497
-327
lines changed

8 files changed

+497
-327
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "https://rubygems.org"
44

55
ruby file: ".ruby-version"
66

7-
gem "rails", "~> 8.0.5"
7+
gem "rails", "~> 8.1.3"
88
gem "rails-i18n", "~> 8.1.0"
99

1010
gem "aws-sdk-s3", "~> 1.218"

Gemfile.lock

Lines changed: 74 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -29,75 +29,78 @@ GEM
2929
GEM
3030
remote: https://rubygems.org/
3131
specs:
32-
actioncable (8.0.5)
33-
actionpack (= 8.0.5)
34-
activesupport (= 8.0.5)
32+
action_text-trix (2.1.18)
33+
railties
34+
actioncable (8.1.3)
35+
actionpack (= 8.1.3)
36+
activesupport (= 8.1.3)
3537
nio4r (~> 2.0)
3638
websocket-driver (>= 0.6.1)
3739
zeitwerk (~> 2.6)
38-
actionmailbox (8.0.5)
39-
actionpack (= 8.0.5)
40-
activejob (= 8.0.5)
41-
activerecord (= 8.0.5)
42-
activestorage (= 8.0.5)
43-
activesupport (= 8.0.5)
40+
actionmailbox (8.1.3)
41+
actionpack (= 8.1.3)
42+
activejob (= 8.1.3)
43+
activerecord (= 8.1.3)
44+
activestorage (= 8.1.3)
45+
activesupport (= 8.1.3)
4446
mail (>= 2.8.0)
45-
actionmailer (8.0.5)
46-
actionpack (= 8.0.5)
47-
actionview (= 8.0.5)
48-
activejob (= 8.0.5)
49-
activesupport (= 8.0.5)
47+
actionmailer (8.1.3)
48+
actionpack (= 8.1.3)
49+
actionview (= 8.1.3)
50+
activejob (= 8.1.3)
51+
activesupport (= 8.1.3)
5052
mail (>= 2.8.0)
5153
rails-dom-testing (~> 2.2)
52-
actionpack (8.0.5)
53-
actionview (= 8.0.5)
54-
activesupport (= 8.0.5)
54+
actionpack (8.1.3)
55+
actionview (= 8.1.3)
56+
activesupport (= 8.1.3)
5557
nokogiri (>= 1.8.5)
5658
rack (>= 2.2.4)
5759
rack-session (>= 1.0.1)
5860
rack-test (>= 0.6.3)
5961
rails-dom-testing (~> 2.2)
6062
rails-html-sanitizer (~> 1.6)
6163
useragent (~> 0.16)
62-
actiontext (8.0.5)
63-
actionpack (= 8.0.5)
64-
activerecord (= 8.0.5)
65-
activestorage (= 8.0.5)
66-
activesupport (= 8.0.5)
64+
actiontext (8.1.3)
65+
action_text-trix (~> 2.1.15)
66+
actionpack (= 8.1.3)
67+
activerecord (= 8.1.3)
68+
activestorage (= 8.1.3)
69+
activesupport (= 8.1.3)
6770
globalid (>= 0.6.0)
6871
nokogiri (>= 1.8.5)
69-
actionview (8.0.5)
70-
activesupport (= 8.0.5)
72+
actionview (8.1.3)
73+
activesupport (= 8.1.3)
7174
builder (~> 3.1)
7275
erubi (~> 1.11)
7376
rails-dom-testing (~> 2.2)
7477
rails-html-sanitizer (~> 1.6)
7578
active_link_to (1.0.5)
7679
actionpack
7780
addressable
78-
activejob (8.0.5)
79-
activesupport (= 8.0.5)
81+
activejob (8.1.3)
82+
activesupport (= 8.1.3)
8083
globalid (>= 0.3.6)
81-
activemodel (8.0.5)
82-
activesupport (= 8.0.5)
83-
activerecord (8.0.5)
84-
activemodel (= 8.0.5)
85-
activesupport (= 8.0.5)
84+
activemodel (8.1.3)
85+
activesupport (= 8.1.3)
86+
activerecord (8.1.3)
87+
activemodel (= 8.1.3)
88+
activesupport (= 8.1.3)
8689
timeout (>= 0.4.0)
87-
activestorage (8.0.5)
88-
actionpack (= 8.0.5)
89-
activejob (= 8.0.5)
90-
activerecord (= 8.0.5)
91-
activesupport (= 8.0.5)
90+
activestorage (8.1.3)
91+
actionpack (= 8.1.3)
92+
activejob (= 8.1.3)
93+
activerecord (= 8.1.3)
94+
activesupport (= 8.1.3)
9295
marcel (~> 1.0)
93-
activesupport (8.0.5)
96+
activesupport (8.1.3)
9497
base64
95-
benchmark (>= 0.3)
9698
bigdecimal
9799
concurrent-ruby (~> 1.0, >= 1.3.1)
98100
connection_pool (>= 2.2.5)
99101
drb
100102
i18n (>= 1.6, < 2)
103+
json
101104
logger (>= 1.4.2)
102105
minitest (>= 5.1)
103106
securerandom (>= 0.3)
@@ -160,7 +163,6 @@ GEM
160163
aws-eventstream (~> 1, >= 1.0.2)
161164
base64 (0.3.0)
162165
bcrypt (3.1.22)
163-
benchmark (0.5.0)
164166
benchmark-ips (2.14.0)
165167
bigdecimal (4.1.1)
166168
bindata (2.5.1)
@@ -376,7 +378,7 @@ GEM
376378
jmespath (1.6.2)
377379
job-iteration (1.12.0)
378380
activejob (>= 6.1)
379-
json (2.19.2)
381+
json (2.19.3)
380382
json-jwt (1.16.7)
381383
activesupport (>= 4.2)
382384
aes_key_wrap
@@ -645,20 +647,20 @@ GEM
645647
rack (>= 1.3)
646648
rackup (2.3.1)
647649
rack (>= 3)
648-
rails (8.0.5)
649-
actioncable (= 8.0.5)
650-
actionmailbox (= 8.0.5)
651-
actionmailer (= 8.0.5)
652-
actionpack (= 8.0.5)
653-
actiontext (= 8.0.5)
654-
actionview (= 8.0.5)
655-
activejob (= 8.0.5)
656-
activemodel (= 8.0.5)
657-
activerecord (= 8.0.5)
658-
activestorage (= 8.0.5)
659-
activesupport (= 8.0.5)
650+
rails (8.1.3)
651+
actioncable (= 8.1.3)
652+
actionmailbox (= 8.1.3)
653+
actionmailer (= 8.1.3)
654+
actionpack (= 8.1.3)
655+
actiontext (= 8.1.3)
656+
actionview (= 8.1.3)
657+
activejob (= 8.1.3)
658+
activemodel (= 8.1.3)
659+
activerecord (= 8.1.3)
660+
activestorage (= 8.1.3)
661+
activesupport (= 8.1.3)
660662
bundler (>= 1.15.0)
661-
railties (= 8.0.5)
663+
railties (= 8.1.3)
662664
rails-controller-testing (1.0.5)
663665
actionpack (>= 5.0.1.rc1)
664666
actionview (>= 5.0.1.rc1)
@@ -682,9 +684,9 @@ GEM
682684
rack
683685
railties (>= 5.1)
684686
semantic_logger (~> 4.16)
685-
railties (8.0.5)
686-
actionpack (= 8.0.5)
687-
activesupport (= 8.0.5)
687+
railties (8.1.3)
688+
actionpack (= 8.1.3)
689+
activesupport (= 8.1.3)
688690
irb (~> 1.13)
689691
rackup (>= 1.0.0)
690692
rake (>= 12.2)
@@ -990,7 +992,7 @@ DEPENDENCIES
990992
rack-sanitizer (~> 2.0)
991993
rack-test (~> 2.2)
992994
rackup (~> 2.3)
993-
rails (~> 8.0.5)
995+
rails (~> 8.1.3)
994996
rails-controller-testing (~> 1.0)
995997
rails-erd (~> 1.7)
996998
rails-i18n (~> 8.1.0)
@@ -1030,18 +1032,19 @@ DEPENDENCIES
10301032
zlib (~> 3.2)
10311033

10321034
CHECKSUMS
1033-
actioncable (8.0.5) sha256=01a1d1a48b63b1a643fae6b7b4eb2859af55f507b335fca9ab869a5c6742bb8b
1034-
actionmailbox (8.0.5) sha256=2651a87c0cc3dd1243a3afe64c052e71138f99006b3a5d3fa519198735500054
1035-
actionmailer (8.0.5) sha256=7918fac842cfe985ed21692f3d212c914a0c816e30e6fa68633177bb22f38561
1036-
actionpack (8.0.5) sha256=c9de868975dd124a0956499140bd5e63c367865deca01292df7c3195c8da4b35
1037-
actiontext (8.0.5) sha256=12f3ce3d6326230728316ba14eeac27b2100d6e7d9bfcb4b01fb27b187a812e1
1038-
actionview (8.0.5) sha256=6d0fa9e63df0cf2729b1f54d0988336c149eb2bbc6049f4c2834d7b62f351413
1035+
action_text-trix (2.1.18) sha256=3fdb83f8bff4145d098be283cdd47ac41caf5110bfa6df4695ed7127d7fb3642
1036+
actioncable (8.1.3) sha256=e5bc7f75e44e6a22de29c4f43176927c3a9ce4824464b74ed18d8226e75a80f0
1037+
actionmailbox (8.1.3) sha256=df7da474eaa0e70df4ed5a6fef66eb3b3b0f2dbf7f14518deee8d77f1b4aae59
1038+
actionmailer (8.1.3) sha256=831f724891bb70d0aaa4d76581a6321124b6a752cb655c9346aae5479318448d
1039+
actionpack (8.1.3) sha256=af998cae4d47c5d581a2cc363b5c77eb718b7c4b45748d81b1887b25621c29a3
1040+
actiontext (8.1.3) sha256=d291019c00e1ea9e6463011fa214f6081a56d7b9a1d224e7d3f6384c1dafc7d2
1041+
actionview (8.1.3) sha256=1347c88c7f3edb38100c5ce0e9fb5e62d7755f3edc1b61cce2eb0b2c6ea2fd5d
10391042
active_link_to (1.0.5) sha256=4830847b3d14589df1e9fc62038ceec015257fce975ec1c2a77836c461b139ba
1040-
activejob (8.0.5) sha256=2dabe5c3bfe284aba4687c52b930564335435dde3a60b047821f9d3bd0d2ea10
1041-
activemodel (8.0.5) sha256=c796813d46dc1373f4c6c0ec91dfc520b53683ea773c3b3f9a12c4b3eb145bc2
1042-
activerecord (8.0.5) sha256=89b261b6cd910c9431cf2475f3f6e5e2f5ce589805043a33ef2b004376a129e6
1043-
activestorage (8.0.5) sha256=25898a3f8f8aced15ea6a8578cb56955acf3a96ad931e000b2e77e9c8db43df3
1044-
activesupport (8.0.5) sha256=37f213ff6a37cf3fadfa1a28c1a9678e2cb73b59bb9ebd0eeeca653cccadcb23
1043+
activejob (8.1.3) sha256=a149b1766aa8204c3c3da7309e4becd40fcd5529c348cffbf6c9b16b565fe8d3
1044+
activemodel (8.1.3) sha256=90c05cbe4cef3649b8f79f13016191ea94c4525ce4a5c0fb7ef909c4b91c8219
1045+
activerecord (8.1.3) sha256=8003be7b2466ba0a2a670e603eeb0a61dd66058fccecfc49901e775260ac70ab
1046+
activestorage (8.1.3) sha256=0564ce9309143951a67615e1bb4e090ee54b8befed417133cae614479b46384d
1047+
activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
10451048
addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af
10461049
aes_key_wrap (1.1.0) sha256=b935f4756b37375895db45669e79dfcdc0f7901e12d4e08974d5540c8e0776a5
10471050
aggregate_assertions (0.3.0) sha256=a5ad621c4b0c451bbd8cf520d5f98caa56882043114954a8725aedd3cba1db11
@@ -1068,7 +1071,6 @@ CHECKSUMS
10681071
aws-sigv4 (1.12.1) sha256=6973ff95cb0fd0dc58ba26e90e9510a2219525d07620c8babeb70ef831826c00
10691072
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
10701073
bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032
1071-
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
10721074
benchmark-ips (2.14.0) sha256=b72bc8a65d525d5906f8cd94270dccf73452ee3257a32b89fbd6684d3e8a9b1d
10731075
bigdecimal (4.1.1) sha256=1c09efab961da45203c8316b0cdaec0ff391dfadb952dd459584b63ebf8054ca
10741076
bindata (2.5.1) sha256=53186a1ec2da943d4cb413583d680644eb810aacbf8902497aac8f191fad9e58
@@ -1163,7 +1165,7 @@ CHECKSUMS
11631165
irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae
11641166
jmespath (1.6.2) sha256=238d774a58723d6c090494c8879b5e9918c19485f7e840f2c1c7532cf84ebcb1
11651167
job-iteration (1.12.0) sha256=0164057417750f6e9c3ed548f029f1136b18eb53975fa438b09304a525d6c6c0
1166-
json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
1168+
json (2.19.3) sha256=289b0bb53052a1fa8c34ab33cc750b659ba14a5c45f3fcf4b18762dc67c78646
11671169
json-jwt (1.16.7) sha256=ccabff4c6d1a14276b23178e8bebe513ef236399b72a0b886d7ed94800d172a5
11681170
jwt (3.1.2) sha256=af6991f19a6bb4060d618d9add7a66f0eeb005ac0bc017cd01f63b42e122d535
11691171
kaminari (1.2.2) sha256=c4076ff9adccc6109408333f87b5c4abbda5e39dc464bd4c66d06d9f73442a3e
@@ -1275,14 +1277,14 @@ CHECKSUMS
12751277
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
12761278
rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
12771279
rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868
1278-
rails (8.0.5) sha256=4cb40f90948be292fa15cc7cb37757b97266585145c6e76957464b40edfd5be6
1280+
rails (8.1.3) sha256=6d017ba5348c98fc909753a8169b21d44de14d2a0b92d140d1a966834c3c9cd3
12791281
rails-controller-testing (1.0.5) sha256=741448db59366073e86fc965ba403f881c636b79a2c39a48d0486f2607182e94
12801282
rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
12811283
rails-erd (1.7.2) sha256=0b17d0fba25d319d8da8af7a3e5e2149d02d6187cc7351e8be43423f07c48bcd
12821284
rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89
12831285
rails-i18n (8.1.0) sha256=52d5fd6c0abef28d84223cc05647f6ae0fd552637a1ede92deee9545755b6cf3
12841286
rails_semantic_logger (4.19.0) sha256=e75e562c68a32abb6a8615940afd7d40c082cff786b8d7b50ff1f7462eff3c16
1285-
railties (8.0.5) sha256=ad98c6e9a096b7e8cf63c70872b60ec6c1d4152be2a4ffa63483ec02a837a9d5
1287+
railties (8.1.3) sha256=913eb0e0cb520aac687ffd74916bd726d48fa21f47833c6292576ef6a286de22
12861288
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
12871289
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
12881290
ransack (4.4.1) sha256=6aeaac36fc19088570e10da1044e6cfd88c740e20f871b84566fd30e32b7a63d

app/avo/concerns/auditable.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,30 @@ def in_audited_transaction(auditable:, admin_github_user:, action:, fields:, arg
4949
auditable:,
5050
action:,
5151
comment: fields.fetch(:comment),
52-
audited_changes: {
52+
audited_changes: normalize_for_json(
5353
records: audited_changed_records,
5454
fields: fields.except(:comment),
5555
arguments: arguments,
5656
models: models&.map { it.to_global_id.uri }
57-
}
57+
)
5858
)
5959

6060
[value, audit]
6161
end
6262
end
63+
64+
# Converts Array/Hash subclasses to plain types to prevent Rails 8.1's
65+
# JSONGemCoderEncoder from calling as_json on them, which would produce
66+
# unexpected structures (e.g., JSON::JWK::Set#as_json returns {keys: [...]})
67+
def normalize_for_json(value)
68+
case value
69+
when Hash
70+
value.to_h { |k, v| [k, normalize_for_json(v)] }
71+
when Array
72+
value.map { |v| normalize_for_json(v) }
73+
else
74+
value
75+
end
76+
end
6377
end
6478
end

app/models/log_ticket.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def self.pop(key: nil, directory: nil)
88
scope = pending.limit(1).lock(true).order(:id)
99
scope = scope.where(key: key) if key
1010
scope = scope.where(directory: directory) if directory
11-
scope.sole.tap do |ticket|
11+
scope.take!.tap do |ticket|
1212
ticket.update_column(:status, "processing")
1313
end
1414
rescue ActiveRecord::RecordNotFound
15-
nil # no ticket in queue found by `sole` call
15+
nil # no ticket in queue found by `take!` call
1616
end
1717

1818
def fs
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# frozen_string_literal: true
2+
3+
# Be sure to restart your server when you modify this file.
4+
#
5+
# This file eases your Rails 8.1 framework defaults upgrade.
6+
#
7+
# Uncomment each configuration one by one to switch to the new default.
8+
# Once your application is ready to run with all new defaults, you can remove
9+
# this file and set the `config.load_defaults` to `8.1`.
10+
#
11+
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
12+
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
13+
14+
###
15+
# Skips escaping HTML entities and line separators. When set to `false`, the
16+
# JSON renderer no longer escapes these to improve performance.
17+
#
18+
# Example:
19+
# class PostsController < ApplicationController
20+
# def index
21+
# render json: { key: "\u2028\u2029<>&" }
22+
# end
23+
# end
24+
#
25+
# Renders `{"key":"\u2028\u2029\u003c\u003e\u0026"}` with the previous default, but `{"key":" <>&"}` with the config
26+
# set to `false`.
27+
#
28+
# Applications that want to keep the escaping behavior can set the config to `true`.
29+
#++
30+
# Rails.configuration.action_controller.escape_json_responses = false
31+
32+
###
33+
# Skips escaping LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) in JSON.
34+
#
35+
# Historically these characters were not valid inside JavaScript literal strings but that changed in ECMAScript 2019.
36+
# As such it's no longer a concern in modern browsers: https://caniuse.com/mdn-javascript_builtins_json_json_superset.
37+
#++
38+
# Rails.configuration.active_support.escape_js_separators_in_json = false
39+
40+
###
41+
# Raises an error when order dependent finder methods (e.g. `#first`, `#second`) are called without `order` values
42+
# on the relation, and the model does not have any order columns (`implicit_order_column`, `query_constraints`, or
43+
# `primary_key`) to fall back on.
44+
#
45+
# The current behavior of not raising an error has been deprecated, and this configuration option will be removed in
46+
# Rails 8.2.
47+
#++
48+
# Rails.configuration.active_record.raise_on_missing_required_finder_order_columns = true
49+
50+
###
51+
# Controls how Rails handles path relative URL redirects.
52+
# When set to `:raise`, Rails will raise an `ActionController::Redirecting::UnsafeRedirectError`
53+
# for relative URLs without a leading slash, which can help prevent open redirect vulnerabilities.
54+
#
55+
# Example:
56+
# redirect_to "example.com" # Raises UnsafeRedirectError
57+
# redirect_to "@attacker.com" # Raises UnsafeRedirectError
58+
# redirect_to "/safe/path" # Works correctly
59+
#
60+
# Applications that want to allow these redirects can set the config to `:log` (previous default)
61+
# to only log warnings, or `:notify` to send ActiveSupport notifications.
62+
#++
63+
# Rails.configuration.action_controller.action_on_path_relative_redirect = :raise
64+
65+
###
66+
# Use a Ruby parser to track dependencies between Action View templates
67+
#++
68+
# Rails.configuration.action_view.render_tracker = :ruby
69+
70+
###
71+
# When enabled, hidden inputs generated by `form_tag`, `token_tag`, `method_tag`, and the hidden parameter fields
72+
# included in `button_to` forms will omit the `autocomplete="off"` attribute.
73+
#
74+
# Applications that want to keep generating the `autocomplete` attribute for those tags can set it to `false`.
75+
#++
76+
# Rails.configuration.action_view.remove_hidden_field_autocomplete = true

0 commit comments

Comments
 (0)