You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cronitor-sidekiq gem relies on the options method of Sidekiq::Periodic::Loop objects to return a hash. However, due to inconsistencies in Sidekiq's own handling of @options serialization and deserialization, the method returns a JSON string instead. This causes a NoMethodError in cronitor-sidekiq. See this related issue sidekiq/sidekiq#6092 I filed with Sidekiq.
Description
The core issue arises from the misalignment between how Sidekiq::Periodic::Loop handles @options serialization and how cronitor-sidekiq expects to consume it.
In Sidekiq::Periodic::Loop, @options is serialized to JSON when stored in Redis:
Option Parsing: To ensure compatibility with both the current and any fixed version of Sidekiq Enterprise, a version-agnostic approach could be to check the type of @options before accessing its keys.
Hi @nohat, thanks for taking the time to document this, and appreciate such a thorough write up! Would you be willing to open a PR that implements your suggested options parsing approach? That looks like a good way to solve it to me.
EDIT: I just read Mike's reply on the issue filed in the Sidekiq repo, and it sounds like the right approach is to just look at the value directly in the job hash.
Summary
The
cronitor-sidekiq
gem relies on theoptions
method ofSidekiq::Periodic::Loop
objects to return a hash. However, due to inconsistencies in Sidekiq's own handling of@options
serialization and deserialization, the method returns a JSON string instead. This causes aNoMethodError
incronitor-sidekiq
. See this related issue sidekiq/sidekiq#6092 I filed with Sidekiq.Description
The core issue arises from the misalignment between how
Sidekiq::Periodic::Loop
handles@options
serialization and howcronitor-sidekiq
expects to consume it.In
Sidekiq::Periodic::Loop
,@options
is serialized to JSON when stored in Redis:However, it is not deserialized back to a hash when read:
In
cronitor-sidekiq
, the assumption is made that@options
will be a hash:Example error
Initializer
Suggested Fix
@options
before accessing its keys.Probably would want to rescue JSON::ParserError
The text was updated successfully, but these errors were encountered: