sidekiq 7.0.4 → 7.0.5

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: fec40f38a40f555d39f3826d0b2b26dd72d500a8e58a35ff2e85436ad5abb2c7
4
+ data.tar.gz: b6b0fde1518951d5715484a046e0732224f819b6c45dba1e18c02e8292b97f55
5
5
  SHA512:
6
- metadata.gz: d71996bea6ee081ab98bf626e0aa3bf3722e4ff1683b982bab4fd43abf371145573f7cd09392688f1db6739c57d3ceaf04834a605264db8c02747bd3eb623350
7
- data.tar.gz: 81a1727add73469a9c2ea14b868e08f99c4b50b3cbc31f6277b312c055d207e285cc8b0ef749bb39b65ba832863b9ef05e7427147642bd7b9795344511b274d7
6
+ metadata.gz: c6e0d60356029b73764a1e57e3e6e570fa8e56758da14f6a16945f502f694d182f71e34b246eed4aaa022b184214f7da8253292deeb3b7540bcf14030b3a1139
7
+ data.tar.gz: 3b03e4b1373288faceaee25ac08e73da00f3923bbbfd925b5b02dc0af6ec0c37fb7d23a14b6ec90be268df0441b974e100aa07462586b41648126d3b4020460a
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,24 @@ 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
+ unless json_safe?(args)
25
+ unsafe_item = json_unsafe_item(args)
22
26
  msg = <<~EOM
23
- Job arguments to #{job_class} must be native JSON types, see https://github.com/sidekiq/sidekiq/wiki/Best-Practices.
27
+ Job arguments to #{job_class} must be native JSON types, but #{unsafe_item.inspect} is a #{unsafe_item.class}.
28
+ See https://github.com/sidekiq/sidekiq/wiki/Best-Practices.
24
29
  To disable this error, add `Sidekiq.strict_args!(false)` to your initializer.
25
30
  EOM
26
- raise(ArgumentError, msg)
31
+
32
+ if mode == :raise
33
+ raise(ArgumentError, msg)
34
+ else
35
+ warn(msg)
36
+ end
27
37
  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
38
  end
34
39
  end
35
40
 
@@ -87,5 +92,28 @@ module Sidekiq
87
92
  def json_safe?(item)
88
93
  RECURSIVE_JSON_SAFE[item.class].call(item)
89
94
  end
95
+
96
+ def json_unsafe_item(item)
97
+ case item
98
+ when String, Integer, Float, TrueClass, FalseClass, NilClass
99
+ nil
100
+ when Array
101
+ item.each do |e|
102
+ unsafe_item = json_unsafe_item(e)
103
+ return unsafe_item unless unsafe_item.nil?
104
+ end
105
+ nil
106
+ when Hash
107
+ item.each do |k, v|
108
+ return k unless String === k
109
+
110
+ unsafe_item = json_unsafe_item(v)
111
+ return unsafe_item unless unsafe_item.nil?
112
+ end
113
+ nil
114
+ else
115
+ item
116
+ end
117
+ end
90
118
  end
91
119
  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.5"
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.5
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-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client