sidekiq 7.0.4 → 7.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e461cc2bc3884aff75bfd57ffb8039f8695e364d34f84e8522cd2fb3ffb8266e
4
- data.tar.gz: bd752a0cc1d6a5be73e51cca34636413db291f92de0bc0723e3cb95b7a34f9dc
3
+ metadata.gz: fce9a2bde54477663fcf80408ba57e3653b7cabad880d442a931f92725c1ee3c
4
+ data.tar.gz: 5f3d322fa77edd6dc83e00f5f3c5c1d2e275830065e4637b778e726f2a08c608
5
5
  SHA512:
6
- metadata.gz: d71996bea6ee081ab98bf626e0aa3bf3722e4ff1683b982bab4fd43abf371145573f7cd09392688f1db6739c57d3ceaf04834a605264db8c02747bd3eb623350
7
- data.tar.gz: 81a1727add73469a9c2ea14b868e08f99c4b50b3cbc31f6277b312c055d207e285cc8b0ef749bb39b65ba832863b9ef05e7427147642bd7b9795344511b274d7
6
+ metadata.gz: 801864880ce896e750649e489d9b0f23e04a0c55ca1f3b3d13282dc71aa495cb7937027843321e10a02027d9316c7bb4f6399b1a58c4a1f66a1a4ca85440d66e
7
+ data.tar.gz: dcab086da52aca3518371632fc92dd469d22266f4b0728ec44ae5c42fbdbfe49485ed0c9244d8d0252b7203ef618304832cf8fb0d1bd95d0368f78bbbd10b7ca
data/Changes.md CHANGED
@@ -2,7 +2,12 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
- HEAD
5
+ 7.0.5
6
+ ----------
7
+
8
+ - More context for debugging json unsafe errors [#5787]
9
+
10
+ 7.0.4
6
11
  ----------
7
12
 
8
13
  - Performance and memory optimizations [#5768, fatkodima]
@@ -17,19 +17,23 @@ module Sidekiq
17
17
 
18
18
  def verify_json(item)
19
19
  job_class = item["wrapped"] || item["class"]
20
- if Sidekiq::Config::DEFAULTS[:on_complex_arguments] == :raise
21
- unless json_safe?(item["args"])
20
+ args = item["args"]
21
+ mode = Sidekiq::Config::DEFAULTS[:on_complex_arguments]
22
+
23
+ if mode == :raise || mode == :warn
24
+ if (unsafe_item = json_unsafe?(args))
22
25
  msg = <<~EOM
23
- Job arguments to #{job_class} must be native JSON types, see https://github.com/sidekiq/sidekiq/wiki/Best-Practices.
26
+ Job arguments to #{job_class} must be native JSON types, but #{unsafe_item.inspect} is a #{unsafe_item.class}.
27
+ See https://github.com/sidekiq/sidekiq/wiki/Best-Practices.
24
28
  To disable this error, add `Sidekiq.strict_args!(false)` to your initializer.
25
29
  EOM
26
- raise(ArgumentError, msg)
30
+
31
+ if mode == :raise
32
+ raise(ArgumentError, msg)
33
+ else
34
+ warn(msg)
35
+ end
27
36
  end
28
- elsif Sidekiq::Config::DEFAULTS[:on_complex_arguments] == :warn
29
- warn <<~EOM unless json_safe?(item["args"])
30
- Job arguments to #{job_class} must be native JSON types, see https://github.com/sidekiq/sidekiq/wiki/Best-Practices.
31
- To disable this warning, add `Sidekiq.strict_args!(false)` to your initializer.
32
- EOM
33
37
  end
34
38
  end
35
39
 
@@ -65,27 +69,37 @@ module Sidekiq
65
69
 
66
70
  private
67
71
 
68
- RECURSIVE_JSON_SAFE = {
69
- Integer => ->(val) { true },
70
- Float => ->(val) { true },
71
- TrueClass => ->(val) { true },
72
- FalseClass => ->(val) { true },
73
- NilClass => ->(val) { true },
74
- String => ->(val) { true },
72
+ RECURSIVE_JSON_UNSAFE = {
73
+ Integer => ->(val) {},
74
+ Float => ->(val) {},
75
+ TrueClass => ->(val) {},
76
+ FalseClass => ->(val) {},
77
+ NilClass => ->(val) {},
78
+ String => ->(val) {},
75
79
  Array => ->(val) {
76
- val.all? { |e| RECURSIVE_JSON_SAFE[e.class].call(e) }
80
+ val.each do |e|
81
+ unsafe_item = RECURSIVE_JSON_UNSAFE[e.class].call(e)
82
+ return unsafe_item unless unsafe_item.nil?
83
+ end
84
+ nil
77
85
  },
78
86
  Hash => ->(val) {
79
- val.all? { |k, v| String === k && RECURSIVE_JSON_SAFE[v.class].call(v) }
87
+ val.each do |k, v|
88
+ return k unless String === k
89
+
90
+ unsafe_item = RECURSIVE_JSON_UNSAFE[v.class].call(v)
91
+ return unsafe_item unless unsafe_item.nil?
92
+ end
93
+ nil
80
94
  }
81
95
  }
82
96
 
83
- RECURSIVE_JSON_SAFE.default = ->(_val) { false }
84
- RECURSIVE_JSON_SAFE.compare_by_identity
85
- private_constant :RECURSIVE_JSON_SAFE
97
+ RECURSIVE_JSON_UNSAFE.default = ->(val) { val }
98
+ RECURSIVE_JSON_UNSAFE.compare_by_identity
99
+ private_constant :RECURSIVE_JSON_UNSAFE
86
100
 
87
- def json_safe?(item)
88
- RECURSIVE_JSON_SAFE[item.class].call(item)
101
+ def json_unsafe?(item)
102
+ RECURSIVE_JSON_UNSAFE[item.class].call(item)
89
103
  end
90
104
  end
91
105
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.0.4"
4
+ VERSION = "7.0.6"
5
5
  MAJOR = 7
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.4
4
+ version: 7.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2023-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []
230
- rubygems_version: 3.4.6
230
+ rubygems_version: 3.4.7
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: Simple, efficient background processing for Ruby